Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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



Advertisement
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:
Advertisements
Advertisements
 

 

 

DMCA.com