import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class App17 {
public static void main(String[] args) throws IOException {
File srcFile = new File("d:\\test.txt");
File outFile = new File("d:\\dest.txt");
InputStreamReader reader = new InputStreamReader(new FileInputStream(srcFile));
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(outFile));
char[] buffer = new char[5];
while(reader.read(buffer) != -1) {
System.out.println(buffer);
writer.write(String.valueOf(buffer).trim() + "\r\n");
}
reader.close();
writer.flush();
writer.close();
}
}