import java.io.*; import java.util.List; public class Test { public static void main(String[] args) throws IOException { File file=new File("D:\\Fantasy\\YJNN\\ndfq\\小CQDw--数学期末冲刺卷"); File[] files=file.listFiles(); InputStream inputStream; OutputStream outputStream; int count=1; for (File file1 : files) { File file2=new File("D:\\Fantasy\\YJNN\\ndfq\\小CQDw--数学期末冲刺卷\\jdwm-"+count+".7z"); inputStream=new FileInputStream(file1); outputStream=new FileOutputStream(file2); byte[] bytes=new byte[8192*4]; int len=inputStream.read(bytes); while (len!=-1){ outputStream.write(bytes,0,len); len=inputStream.read(bytes); } System.out.println(count++); } } }
java文件的读取和写出
最新推荐文章于 2024-04-07 17:29:19 发布