As a java beginnners what i incline to do for my program almost get solution from this site.
Right now i need a small help to get file name or full path for output files of my program. so far my program is running as a search engine to find all of my friends name from many files and compare the similarity with a constructor "LCS".
the part of my code:
FileReader reader; BufferedReader br;
String result=""; String word= new String();
String target = "friend";
ArrayList names = new ArrayList();
try{ //read many files from folder
File directory = new File("C:/Users/Test");
File file[]= directory.listFiles();
for (File allFiles: file) {
reader = new FileReader (allFiles);
br = new BufferedReader(reader);
Scanner scan = new Scanner(reader);
while(scan.hasNext()){ scan.next();
result = scan.findWithinHorizon(target,0);
if(result!=null) {
word = (scan.next() + scan.findWithinHorizon("", 0));
names.add(word)
for (String found: names){ }
}
}
scan.close();
br.close();
}
Scanner scanner = new Scanner(System.in);
String searchName;
System.out.print("Enter name to Search : ");
searchName = scanner.next();
for (String found: names) {
double compare = ReadFilesAndCompare.LCS(found, searchName);
//if (compare >= 50.0) {
System.out.println("Found names : "+found+ "\t" +"Similarity score: " +compare); }
what should i use here to getFile name for my found result ??
Can you please give a easiest solution for me ?