```java
import java
.io
.File
;
import java
.io
.FileReader
;
import java
.io
.FileWriter
;
import java
.io
.IOException
;
import java
.io
.Reader
;
import java
.io
.Writer
;
public class IO_Test04 {
public static void main(String
[] args
) {
File srcFile
= new File("io.txt");
File desFile
= new File("FileWriter.txt");
Reader reader
= null
;
Writer writer
= null
;
try {
reader
= new FileReader(srcFile
);
writer
= new FileWriter(desFile
);
int inputTemp
= -1;
char[] inputFlush
= new char[1024];
while ((inputTemp
= reader
.read(inputFlush
)) != -1) {
writer
.write(inputFlush
, 0, inputFlush
.length
);
}
} catch (Exception e
) {
} finally {
try {
if (writer
!= null
)
writer
.close();
} catch (IOException e
) {
e
.printStackTrace();
}
if (reader
!= null
) {
try {
reader
.close();
} catch (IOException e
) {
e
.printStackTrace();
}
}
}
}
}
转载请注明原文地址: https://mac.8miu.com/read-74111.html