The data.txt contains:
PM| ||1|XX|PID|HOT|PLAZA|NO. 4|Main Description|
The data.txt must change to the data below:
PM|null|null|1|XX|PID|HOT|PLAZA|NO. 4|Main Description
I have an error with my loop. Any help why it's not working would be very appreciated?
import java.io.*;
import java.util.*;
public class App8 {
public App8 ( ) throws IOException{
BufferedReader br = new BufferedReader(new FileReader(new File("data.txt")));
int j = 0;
String rawString = null;
String modifiedString = null;
while( (rawString = br.readLine() ) != null)
{
//if( (j = rawString.indexOf("| |")) > 0 )
//Changes made here, It does not work, Could you help
////////////////// problem here, need a loop here ///////
while (((j = rawString.indexOf("| |")) > 0))
{
StringBuffer sb = new StringBuffer(rawString);
sb.replace(j,j+2,"|null|");
modifiedString = sb.toString();
}
}
//Verify output (:NB: This will only print out the last value)
System.out.println(modifiedString);
} //end of constructor
public static void main ( String args[] ) throws IOException {
new App8();
}//End of Main Method
} // End of Application