public static void main(String[] args) {
try {
File in = new File("d:/FileTest.txt");
File out = new File("d:/FileTest2.txt");
FileReader fr = new FileReader(in);
FileWriter fw = new FileWriter(out);
// InputStreamReader isr = new InputStreamReader(new FileInputStream(in));
// OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(out));
BufferedReader br = new BufferedReader(fr);
BufferedWriter bw = new BufferedWriter(fw);
// System.out.println("in-encoding:" + isr.getEncoding());
// System.out.println("out-encoding:" + osw.getEncoding());
// System.out.println(in.length());
int c;
long line;
if(in.length() % 10 == 0) {
line = in.length()/10;
} else {
line = in.length()/10 + 1;
}
// System.out.println(line);
for (int j = 0; j < line; j++) {
for (int i = 0; i < 5 && (c=br.read()) != -1; i++) {
bw.write(c);
}
bw.newLine();
}
br.close();
bw.close();
} catch (Exception e) {
e.printStackTrace();
}
}
try {
File in = new File("d:/FileTest.txt");
File out = new File("d:/FileTest2.txt");
FileReader fr = new FileReader(in);
FileWriter fw = new FileWriter(out);
// InputStreamReader isr = new InputStreamReader(new FileInputStream(in));
// OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(out));
BufferedReader br = new BufferedReader(fr);
BufferedWriter bw = new BufferedWriter(fw);
// System.out.println("in-encoding:" + isr.getEncoding());
// System.out.println("out-encoding:" + osw.getEncoding());
// System.out.println(in.length());
int c;
long line;
if(in.length() % 10 == 0) {
line = in.length()/10;
} else {
line = in.length()/10 + 1;
}
// System.out.println(line);
for (int j = 0; j < line; j++) {
for (int i = 0; i < 5 && (c=br.read()) != -1; i++) {
bw.write(c);
}
bw.newLine();
}
br.close();
bw.close();
} catch (Exception e) {
e.printStackTrace();
}
}