文件转文件流,本地和远程

来源:互联网 发布:js中数组删除指定元素 编辑:程序博客网 时间:2024/05/18 15:25
 // in1为  本地文件图片地址转换成流(例如:D:\13071494\pic\test.jpg)
File file = new File(path);
InputStream in1 = new FileInputStream(file);
            
// in2 为网络地址图片地址转换成流(例如: http://10.19.95.100/uimg/sop/commodity/1_x.jpg)
 java.net.URL url = new java.net.URL(path);
URLConnection conn = url.openConnection();
InputStream in2 = conn.getInputStream();