As long as the log file is locked for write access only, you can copy it, as @ karim79 suggested. After that, the copy belongs to you so that you can do whatever you like with it.
Here is some code that should do what you need to do - it just copies the byte file into the System.out stream:
public class Main {
public static void main(String[] args) throws IOException {
File file = new File("path/to/your/logs/example.log");
long size = file.length();
InputStream is = new FileInputStream(file);
BufferedInputStream bis = new BufferedInputStream(is);
long byteCount=0;
int result;
do {
result = bis.read();
if (result != -1)
{
System.out.write(result);
} else {
break;
}
byteCount++;
} while (byteCount<size);
System.out.printf("%nBytes read=%d",byteCount);
bis.close();
is.close();
}
}
And there you go.
Notes on log files
(, > 1 ), , , (, 1 ), (, vim).