Why the null Pointer exception is comming?

Ads
 

Why the null Pointer exception is comming?

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.

Ads









Related Tutorials/Questions & Answers:
Why the null Pointer exception is comming? - Java Beginners
null pointer exception in java
Advertisements
Httpservletresponse null pointer exception.
Null Pointer Exception
NULL POINTER EXCEPTION
what is a null pointer exception in java
null pointer exception in jsp
NUll POINTER EXCEPTION
Java null pointer exception
Java null pointer exception handling
Null pointer exception in hibernate - Hibernate
Null Pointer Exception - Java Beginners
null pointer exception cannot be removed
Getting Null pointer Exception in the jsp page
Getting Null pointer Exception in the jsp page
Getting Null pointer Exception in the jsp page
Getting Null pointer Exception in the jsp page
Null Pointer Exception
Null pointer exception error in Jsp - JSP-Servlet
Null pointer exception error in Jsp - JSP-Servlet
Handle Null Pointer Exception while text file upload
when do we get null pointer exception in java
null pointer
Null pointer execption
Null pointer execption
Clicking F5 and reentering value throws Null pointer exception
null pointer exceptions
null pointer error
null pointer error
check null exception java
Why string is storing null value - IoC

Ads