IO流之大文件读写

public class Test {
public static void main(String[] args) {
InputStream inputStream = null;
OutputStream outputStream = null;
try {
inputStream = new FileInputStream("D:"+File.separator+"from.txt");
outputStream = new FileOutputStream("D:"+File.separator+"to.txt");
byte[] buffer = new byte[1024];

while(true) {
int temp = inputStream.read(buffer, 0, buffer.length);//将from.txt中的内容输入到buffer中
if(temp == -1) {
break;
}
outputStream.write(buffer, 0, temp);//将buffer中的内容输出到to.txt中
}

} catch (Exception e) {
e.printStackTrace();
} finally {
try {
inputStream.close();
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

原文地址:https://www.cnblogs.com/zhangkefan/p/4756433.html