Home Answers Viewqa Java-Beginners Why the null Pointer exception is comming?

 
 


Nirman
Why the null Pointer exception is comming?
2 Answer(s)      5 years ago
Posted in : Java Beginners

View Answers

June 19, 2008 at 6:49 PM


Hi friend,

import java.io.*;
import java.util.*;
import java.util.regex.Pattern;

public class ReplaceTool{

public static void main(String args[]) throws IOException {
BufferedReader bf = new BufferedReader(new FileReader("Context.txt"));
BufferedReader bf1 = new BufferedReader(new FileReader("amar.txt"));
System.out.println("welcome to india");
String []oldOne = null;
String []newOne = null;
int i = 0;
int count = 0;
String delimiter = "[,]";
int[]limit = {0};
String line;
String line1;
String[] tokens = null;

while((line = bf.readLine())!= null){
for(int j=0; j<count; j++){
int limits= 0;
tokens = line.split(delimiter,limits);
oldOne[i] = tokens[0];
System.out.println("tokens[0] = "+tokens[0]);
System.out.println("tokens[1] = "+tokens[1]);

System.out.println(count);
}
}
while((line1 = bf1.readLine())!= null){
for(i=0;i<count;i++){
String res = line1.replaceAll(oldOne[i], newOne[i]);
System.out.println(res);
}
}

}
}
-------------------------

Read for more information,

http://www.roseindia.net/java/

Thanks

June 19, 2008 at 6:54 PM


Hi friend,

import java.io.*;
import java.util.*;
import java.util.regex.Pattern;

public class ReplaceTool{

public static void main(String args[]) throws IOException {
BufferedReader bf = new BufferedReader(new FileReader("Context.txt"));
BufferedReader bf1 = new BufferedReader(new FileReader("amar.txt"));
System.out.println("welcome to india");
String []oldOne = null;
String []newOne = null;
int i = 0;
int count = 0;
String delimiter = "[,]";
int[]limit = {0};
String line;
String line1;
String[] tokens = null;

while((line = bf.readLine())!= null){
for(int j=0; j<count; j++){
int limits= 0;
tokens = line.split(delimiter,limits);
oldOne[i] = tokens[0];
System.out.println("tokens[0] = "+tokens[0]);
System.out.println("tokens[1] = "+tokens[1]);

System.out.println(count);
}
}
while((line1 = bf1.readLine())!= null){
for(i=0;i<count;i++){
String res = line1.replaceAll(oldOne[i], newOne[i]);
System.out.println(res);
}
}

}
}

------------------------------

Read for more information.

http://www.roseindia.net/java/

Thanks.









Related Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.