下载文件乱码问题

1.下载文件乱码问题     new String("免责声明.pdf".getBytes("utf-8"), "ISO-8859-1");

2.图片转blog

String path = request.getSession().getServletContext().getRealPath("/");
                String a = picturename2.replace(
                        "http://localhost:8080/sp-smsappointment/", "");
                File f = new File(path + a); // 声明File对象
                InputStream input = null; // 准备好一个输入的对象
                input = new FileInputStream(f); // 通过对象多态性,进行实例化
                byte b[] = new byte[(int) f.length()]; // 数组大小由文件决定
                int len = 0;
                int temp = 0; // 接收每一个读取进来的数据
                while ((temp = input.read()) != -1) {
                    b[len] = (byte) temp;
                    len++;
                }
                input.close();
                registeduser.setIdcardphoto2(b);

 

posted on 2014-07-12 21:11  九条命  阅读(516)  评论(0编辑  收藏  举报