public static void main(String[] args) {
File file = new File("D:\\GBJ_TOOLS\\download\\apache-maven-3.3.9-bin.zip");
File file2 = new File("D:\\GBJ_TOOLS\\download\\apache-maven-3.3.9-bin-2.zip");
if (!file2.exists()) {
try {
file2.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
FileInputStream fis = null;
FileOutputStream fos = null;
try {
byte[] a = new byte[(int) file.length()];
fis = new FileInputStream(file);
BufferedInputStream bis = new BufferedInputStream(fis);
bis.read(a);
fos = new FileOutputStream(file2);
fos.write(a);
fis.close();
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
读取文件到byte[]数组,将byte[]写入到指定文件中
最新推荐文章于 2024-08-04 03:52:42 发布