I am loading a CSV file and kept alive without closing BufferReader. Now I want to add/delete few more rows to my CSV and get updated CSV. Which means I want dynamically notified when CSV file is altered.
Here is my sample code:
public class Check {
public static void main(String args[]) throws IOException, InterruptedException{
Check ch = new Check();
//args[0] = "C:\\Users\\raponnam\\Desktop\\GxDefault.csv";
String csvFile="C:\\Users\\raponnam\\Desktop\\GxDefault.csv";
int lineCounter=0;
if (csvFile!=null)
{
BufferedReader csvToRead = null;
try{
csvToRead = new BufferedReader(new FileReader(csvFile));
String line;
while ((line=csvToRead.readLine())!=null)
{
lineCounter++;
String[] splitLine = line.split(",");
System.out.println("no of lines-->> "+lineCounter);
}
while(true)
{
System.out.println("wait 6 seconds");
Thread.sleep(6000);
}
}finally{
//csvToRead.close();
}
}
}
}