I know locally it is possible to get file content line by line.
just like
Scanner s = new Scanner(new File("D:\\Users\\qding\\Desktop\\spy.log"));
while (s.hasNextLine()) {
String line = s.nextLine();
System.out.println("[Method Server] " + line);
}
Is it possible to get file content from remote (Windows/Linux)?
Also, on the remote, the file was a log file, and it is updated always. So the second question is if is possible to file content continuously (with multiple thread?)?
A1. Yes it is possible to get file content from remote system, provided it is accessible over any protocol.
A2. On unix systems, to read content of a file that is changing continuously, we have
tail -f ...command. Please refer to File Monitoring. And to read such files over network, you definitely require help of Threads to wait and read the updates. Apache commons has customtailimplementations that may help you.You can refer to a similar posting on SO, for detailed suggestions and discussions.
Update:
A2: For windows, there is a third party GUI tool Tail for Win32, but never I worked on it.
You can also refer to some more suggestions at Windows … equivalent of “tail -f”?.