Questions tagged [system.out]

Predefined stream object attached to the standard output in Java console applications.

It's a static variable in Java's System class. This tag is intended for questions about Java applications that write to the standard output.

404 questions
4
votes
3 answers

System.out.println vs PrintWriter performance comparison?

I want to print 1 million lines to stdout. System.out.println(result); Or PrintWriter out = new PrintWriter(System.out); out.println(result); out.flush(); To get better performance(speed wise), which one should I use and why? --Edit-- How about…
noooooooob
  • 1,872
  • 3
  • 21
  • 27
4
votes
2 answers

Write all System.out into a file

I have a large program in which I have used System.out for debugging. But I'd like to be able to log all System.out simultaneously to a file so even if my program isn't run in the console all the System.out will be written to a file and I will be…
Johnny
  • 1,509
  • 5
  • 25
  • 38
4
votes
1 answer

how do I use System.out.printf?

My teacher wants us to display our values in the format method (at the very bottom) but the problem is we had a sub and she didn't show us how to use it and my teacher is being less than helpful. Any advice or help would be greatly…
PandaBear
  • 53
  • 1
  • 1
  • 5
4
votes
1 answer

Java - Redirecting system.out.println to a JLabel

I want to redirect a sytem.out.println to a JLabel in another class. I have 2 classes, NextPage and Mctrainer. NextPage is basically just a Jframe (The gui for my project), and I have created a Jlabel in Nextpage using this code; public class…
user1880046
  • 59
  • 1
  • 1
  • 2
4
votes
3 answers

Why does System.out.print cause autoflush?

System.out is a PrintStream object. I read the documentation on PrintStream. What I don't get is why System.out.print causes the buffer to be flushed? Shouldn't that happen only for println?
Chatterjee
  • 299
  • 2
  • 9
3
votes
2 answers

Strange output when running a loop

Can anyone tell me why I always have this strange output after running this loop? Is this a threading issue or what? for(int i=0;i<10;i++){ System.out.println("out: "+i); System.err.println("err: "+(i+1)); } ->OUTPUT: err: 1 …
imanis_tn
  • 1,150
  • 1
  • 12
  • 33
3
votes
2 answers

Does System.out.println() have any other use than printing output to the console?

I was asked the following question during an interview: Does System.out.println() have any other use than printing output to the console?
3
votes
1 answer

Checkstyle Regexp to catch all console printing in Java

I have this Checkstyle block to stop people from printing to console in my project:
wilmol
  • 1,429
  • 16
  • 22
3
votes
2 answers

Is it possible to write a correct and portable console-output "hello world" in JAVA?

I am new to JAVA and could not find yet a way to write a "hello world"-application that works correctly without any change on all platforms and also detects and handles output errors. In particular, I would like to port the following portable C…
3
votes
4 answers

Catalina.out doesn't exist

I want to read my console output logs, and I know that they are stored into "log" folder under the file catalina.out, but it doesn't exists! I have tried in different ways with no results. I don't know how to figure it out, I just want to see my…
Giacomo Brunetta
  • 1,409
  • 3
  • 18
  • 38
3
votes
1 answer

Alternative to System.out to display error messages in a console based application

I am developing a console based application. Is it a good idea to use System.out.println() to display error messages on the console? I am using a lot of these in my classes for error handling. My class looks something like this: public void…
3
votes
1 answer

Tabular Format / printf Spacing in Java Assistance

So this snippet of code has been bugging me for the past hour or so. Basically, part of my program's task is to display data in a sort of tabular format. Only thing left is to just make the output look nice, so to speak. Here is the (example)…
3
votes
1 answer

Cygwin encoding difficulties

Not sure whether this is a programming problem. I began to suspect so... but then I ran the Java program (executable jar) in question in a Windows console instead of a Cygwin one... and it ran fine: output accents fine, accented input accepted fine.…
mike rodent
  • 14,126
  • 11
  • 103
  • 157
3
votes
1 answer

Resetting FileInputStream in Java so I can run multiple instances of another program in a test program

My problem is that I was assigned to modify and improve upon a program that does LZW compression. My program, as far as I know, runs fine, but relies on System.in and System.out redirection for the input file and output file. For my test program, I…
3
votes
4 answers

How can I create a simple 4x3 two dimensional array in Java?

I've got it down in C++, but Java is proving more challenging to me. Here's what i have. I simply want it to have 4 rows and 3 columns initialized to 1-12 and to print it to the screen. Are my errors apparent to you? Thanks! I get 13 errors :( …
Ben
  • 111
  • 2
  • 9