public class Exam3Test8 {
public static void main(String[] args) throws Exception {
appendLineNumber(new File("D:/input.txt"), new File("D:\\output.txt"));
}
public static void appendLineNumber(File from, File to) throws Exception {
BufferedReader in = new BufferedReader(new FileReader(from));
StringBuilder sb = new StringBuilder();
String t;
int lineNumber = 1;
while ((t = in.readLine()) != null) {
sb.append(lineNumber + " ");
sb.append(t);
sb.append(System.getProperty("line.separator"));
lineNumber++;
}
in.close();
BufferedWriter out = new BufferedWriter(new FileWriter(to));
out.write(sb.toString());
out.close();
}
}