vik_2010
February 12th, 2010, 05:29 AM
Sorry for bringing up an old thread. But if anyone could help me with this, I'd appreciate it.
I'm trying to write a simple java program that uses I/O streams, taking input from one file and outputting it into another. I'm taking input from the windowspager.ini file (courtesy Jochen Baier, creator of the program) and outputting it to a file on my desktop.
import java.io.*;
public class firstClass {
public static void main(String[] args) throws IOException {
System.out.println("Hello world");
System.out.println("We are going to create a txt file");
BufferedReader bi = new BufferedReader(new FileReader("C:\\Users\\Vikram\\Desktop\\windowspager-0.90\\windowspager-0.90\\windowspager64bit\\Windowspager.ini"));
BufferedWriter out = new BufferedWriter(new FileWriter("C:\\Users\\Vikram\\Desktop\\out.txt"));
while (bi.readLine() != null) {
String line = bi.readLine();
out.write(line);
out.write("\r\n");
System.out.println("Writing...");
}
System.out.println("Done");
bi.close();
out.close();
}
}
The problem is that the file created only has every OTHER line in the original. I'm not sure if it has something to do with the carriage return+line feed combo, since I'm not used to it as I usually work on Ubu.
If anyone could just point out what's going on, I would appreciate it.
I'm trying to write a simple java program that uses I/O streams, taking input from one file and outputting it into another. I'm taking input from the windowspager.ini file (courtesy Jochen Baier, creator of the program) and outputting it to a file on my desktop.
import java.io.*;
public class firstClass {
public static void main(String[] args) throws IOException {
System.out.println("Hello world");
System.out.println("We are going to create a txt file");
BufferedReader bi = new BufferedReader(new FileReader("C:\\Users\\Vikram\\Desktop\\windowspager-0.90\\windowspager-0.90\\windowspager64bit\\Windowspager.ini"));
BufferedWriter out = new BufferedWriter(new FileWriter("C:\\Users\\Vikram\\Desktop\\out.txt"));
while (bi.readLine() != null) {
String line = bi.readLine();
out.write(line);
out.write("\r\n");
System.out.println("Writing...");
}
System.out.println("Done");
bi.close();
out.close();
}
}
The problem is that the file created only has every OTHER line in the original. I'm not sure if it has something to do with the carriage return+line feed combo, since I'm not used to it as I usually work on Ubu.
If anyone could just point out what's going on, I would appreciate it.