package newpackage3;
/**
*
* @author rajani
*/
import java.io.*;
import java.util.Scanner;
import java.util.regex.MatchResult;
public class Test {
public static void main(String[] args) throws FileNotFoundException {
int count=0,count2=0;
//MatchResult mr;
Scanner s = new Scanner(new File("amazon.txt"));
Scanner s1 = new Scanner(new File("amazoncomp.txt"));
while (null != s.findWithinHorizon("java", 0)) {
count=1;
MatchResult mr = s.match();
// System.out.printf("Word found: %s at index %d to %d.%n", mr.group(),
// mr.start(), mr.end());
}
while (null != s1.findWithinHorizon("java", 0)) {
count2=1;
MatchResult mr = s1.match();
//System.out.printf("Word found: %s at index %d to %d.%n", mr.group(),mr.start(), mr.end());
}
s.close();
if(count==1)
{
System.out.printf("amazon.txt file data found ");
}
if(count2==1)
{
System.out.printf("amazoncomp.txt file data found ");
}
}
}
/**
*
* @author rajani
*/
import java.io.*;
import java.util.Scanner;
import java.util.regex.MatchResult;
public class Test {
public static void main(String[] args) throws FileNotFoundException {
int count=0,count2=0;
//MatchResult mr;
Scanner s = new Scanner(new File("amazon.txt"));
Scanner s1 = new Scanner(new File("amazoncomp.txt"));
while (null != s.findWithinHorizon("java", 0)) {
count=1;
MatchResult mr = s.match();
// System.out.printf("Word found: %s at index %d to %d.%n", mr.group(),
// mr.start(), mr.end());
}
while (null != s1.findWithinHorizon("java", 0)) {
count2=1;
MatchResult mr = s1.match();
//System.out.printf("Word found: %s at index %d to %d.%n", mr.group(),mr.start(), mr.end());
}
s.close();
if(count==1)
{
System.out.printf("amazon.txt file data found ");
}
if(count2==1)
{
System.out.printf("amazoncomp.txt file data found ");
}
}
}
No comments:
Post a Comment