Why the null Pointer exception is comming?

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.









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
check null exception java
null pointer exceptions
null pointer error
null pointer error
Why string is storing null value - IoC
Refresh Button returns null point exception when clicked
pointer
Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database
Why the null values are stored in Database when I am sending proper values?
pointer error java
show null point Exception """ while trying 2 load a JComboBox"" data is fetch from database ms-access
show null point Exception """ while trying 2 load a JComboBox"" data is fetch from database ms-access
show null point Exception """ while trying 2 load a JComboBox"" data is fetch from database ms-access
Pointer a variable
is there is pointer in java or not??
exception
exception
java.lang.NumberFormatException: null
exception
exception
exception
Exception
exception
exception

Ads