首页 > 代码库 > java 流读写文件

java 流读写文件

 public static void createFileToNewPath(InputStream inStream, String newPath) {        try {            int bytesum = 0;            int byteread = 0;            FileOutputStream fs = new FileOutputStream(newPath);            byte[] buffer = new byte[1444];            while ((byteread = inStream.read(buffer)) != -1) {                bytesum += byteread; // 字节数 文件大小                fs.write(buffer, 0, byteread);            }            inStream.close();        } catch (Exception e) {            e.printStackTrace();        }    }

 

java 流读写文件