import java.util.*; import java.io.*; public class getdata { public static void main(String []args){ try{ ArrayList a=new ArrayList(); File testfile = new File("D:\\test.txt"); Scanner test=new Scanner(testfile); int notcount=0; int goodcount=0; int badcount=0; File file1 = new File("D:\\good.txt"); Scanner goodFile = new Scanner (file1); File file2 = new File("D:\\Bad.txt"); Scanner badFile=new Scanner(file2); test.useDelimiter(" "); while(test.hasNext()){ String text=test.next(); if(text.equals("not")){ notcount++; } a.add(text); } badFile.useDelimiter(","); while(badFile.hasNext()) { String word=badFile.next(); for(int i=0;i<a.size();i++){ if(word==a.get(i)) { badcount++; } } } goodFile.useDelimiter(","); while(goodFile.hasNext()) { String word=goodFile.next(); for(int i=0;i<a.size();i++){ if(word.equals(a.get(i))) { goodcount++; } } } if(notcount==1){ if(goodcount!=0){ goodcount=goodcount-1; badcount=badcount+1; } else if(badcount!=0){ badcount=badcount-1; goodcount=goodcount+1; } } System.out.println("negative remarks"+badcount); System.out.println("positive remarks"+goodcount); } catch(IOException e){ System.out.println("File not found"); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)