您的位置:首页 > 编程语言 > Java开发

java 获取本地文件字节数组

2017-09-06 20:03 253 查看
BufferedInputStream in = new BufferedInputStream(new FileInputStream("f:/2.jpg"));
        ByteArrayOutputStream out = new ByteArrayOutputStream(1024);    
       
        byte[] temp = new byte[1024];        
        int size = 0;        
        while ((size = in.read(temp)) != -1) {        
            out.write(temp, 0, size);        
        }        
        in.close();  
        byte[] content = out.toByteArray();  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: