码迷,mamicode.com
首页 > 其他好文 > 详细

下载文件乱码问题

时间:2014-07-13 23:17:43      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:blog   http   文件   os   数据   问题   

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);

 

下载文件乱码问题,布布扣,bubuko.com

下载文件乱码问题

标签:blog   http   文件   os   数据   问题   

原文地址:http://www.cnblogs.com/bigcatllt/p/3840431.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!