`Inline Code Example Here`
import java.io.*;
import java.util.regex.*;
String []str = {"123","0959","75443","19908","1","11879","1119","276","566777","7","675","4435","54","6588","99","124","78"};
String filename = "temp.text";
try{
File file = new File(filename);
FileWriter fw = new FileWriter(file);
for(int i=1;i<=str.lenght;i++){ // Start for
BufferedWriter bw = new BufferedWriter(fw);
bw.write(str);
bw.newLine();
} // End for
bw.close();
}catch(IOException ex){
System.out.println("Error.."+filename+" ");
}
public void Search_Digit(String str){ // Start serch
String line = "";
try{ // Start try
FileReader file = new FileReader(filename);
BufferedReader br = new BufferedReader(file);
while ((line = br.readLine()) !=null)
{ // Start while
System.out.println(line);
} // End while
br.close();
Pattern p = Pattern.compile("(\\d+){3}");
Matcher m = p.matcher(line);
while(m.find()){
System.out.println( "Found" + m.group(1));
} // End while
}catch(FileNotFoundException ex){
System.out.println("Unable to open File "+filename+"");
}
catch(IOException ex){
System.out.println("ERROR WRITING TO FILE"+ filename +"");
}
} // End search
public static void main(String[]args){
Find_digit obj = new Find_digit();
obj.Search_Digit(str);
}
}
loveparadise 0 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
loveparadise 0 Newbie Poster
loveparadise 0 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
loveparadise 0 Newbie Poster
loveparadise 0 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
loveparadise 0 Newbie Poster
stultuske 1,116 Posting Maven Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
loveparadise 0 Newbie Poster
loveparadise 0 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
loveparadise 0 Newbie Poster
loveparadise 0 Newbie Poster
stultuske 1,116 Posting Maven Featured Poster
loveparadise 0 Newbie Poster
loveparadise 0 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
loveparadise 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.