- #1
eXorikos
- 284
- 5
I'm writing a script that changes the format of a datafile into a more suitable format for us to import it in Origin. The problem is that it only writes until line 2179, but it is supposed to write until it reaches 4096, where the datafile also ends.
Code:
public static void main(String[] args) {
try
{
BufferedReader inputStream = new BufferedReader(new FileReader("am0001.dat"));
PrintWriter outputStream = new PrintWriter(new FileOutputStream("am0001.csv"));
int count = 0;
String line = inputStream.readLine();
boolean quit = false;
while(quit != true){
if(line.equals("[ADC 1 Spectrum]")){
outputStream.println("Channel;ADC 1");
line = inputStream.readLine();
int adc1 = 4096;
while(count < adc1){
count++;
outputStream.println(count + ";" + line);
line = inputStream.readLine();
}
quit = true;
System.out.println("quit");
}
else{
System.out.println(line);
line = inputStream.readLine();
}
}
System.out.println("The data was succesfully transferred to test.csv");
}
catch(FileNotFoundException e)
{
System.out.println("File opening problem.");
}
catch(IOException e)
{
System.out.println("Error reading from file test.dat");
}
}