top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Java:How could Java classes direct program messages to the system console but error messages say to file?

0 votes
678 views
Java:How could Java classes direct program messages to the system console but error messages say to file?
posted Sep 5, 2013 by Vinay Shukla

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

The class System has a variable out that represents the standard output, and the variable err that represents the standard error device. By default they both point at the system console. This how the standard output could be re-directed: Stream st = new Stream(new FileOutputStream("output.txt")); System.setErr(st); System.setOut(st);

answer Sep 5, 2013 by Arvind Singh
Similar Questions
0 votes

I run my code in Eclipse IDE and its fine. I have export it as jar file from Eclipse and run on terminal as jar file, it generates Error: java.lang.NullPointerException. Could not understand why is it so.

+3 votes

If you use fread to read a file of unknown size with a set buffer size of say 500 bytes, when you get to the end of the file you are likely to read a stub of 500 bytes of info and the eof marker.

And fread will not read that block and set and oef that can be read with feof. That is how I understand, so we can either use fseek to discover the file size and fread accordingly or use fstat?

Is this the proper approach?

...