public class IoCopyText01 {
public static void main(String[] args) {
FileOutputStream fio = null;
FileInputStream fis = null;
try {
fis = new FileInputStream("C:\\Users\\11026\\Desktop\\1611539565799.docx");
fio = new FileOutputStream("D:\\Text\\1611539565799.docx");
byte[] byt = new byte[1024 * 1024];
int count = 0;
while((count = fis.read(byt)) != -1){
fio.write(byt,0,count);
}
fio.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fio != null) {
try {
fio.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
public class CopyText02 {
public static void main(String[] args) {
FileWriter in = null;
FileReader out = null;
try {
in = new FileWriter("D:\\Text\\NEWS.txt");
out = new FileReader("D:\\NEWS.txt");
char[] chars = new char[4];
int readCount = 0;
while((readCount = out.read(chars)) != -1){
in.write(chars,0,readCount);
}
in.flush();
} catch (IOException e) {
e.printStackTrace();
}finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}