Questions tagged [printstream]

175 questions
1
vote
2 answers

How does Out variable which is defined static and assigned null in System class can access non-static methods of PrintStream class.

As to access the methods of PrintStram class an object must be created, so how the out variable is able to access those methods when it is assigned null. public final static PrintStream out = null; This is the declaration in System class. I…
Prafull Bajpai
  • 33
  • 1
  • 2
  • 5
1
vote
2 answers

In what conditions the checkError() method of the PrintStream object returns true?

As given in JAVA docs, the variable 'trouble' gets set to true whenever there is a java.io.IOException. I write a program: import java.io.*; class First { public static void main(String[] args) throws Exception { File…
my name is GYAN
  • 1,269
  • 13
  • 27
1
vote
1 answer

PrintStream - how to write inside an already created file

I want to write the results of my tests to an already created text file using PrintStream. Unfortunately i only know about this statement PrintStream out = new PrintStream(new FileOutputStream("Results.txt")) but this is creating a new file.…
Tudor
  • 199
  • 3
  • 14
1
vote
1 answer

How to tie a PrintStream to the System.out and err streams

I'm trying to tie my PrintStream object to the console's output and error streams so that whatever I write there will also be written to my log file. public static void tieOutputStreams(String fileName) { try { File output = new…
Raam
  • 63
  • 1
  • 8
1
vote
1 answer

Java Print Stream printing spaces

I'm trying to print out a collection of words to a CSV file and am trying to avoid spaces being printed as a word. static TreeMap wordHash = new TreeMap(); Set words=wordHash.entrySet(); Iterator it =…
CS2016
  • 331
  • 1
  • 3
  • 15
1
vote
2 answers

Why is flushing not working on System.err?

I'm developing a main class that writes potential exceptions by means of e.printStackTrace() and which finishes with System.err.flush(); System.out.println("\n>>> EXITING..."); The issue is that when exception trace is big, my exiting message is…
Whimusical
  • 6,401
  • 11
  • 62
  • 105
1
vote
2 answers

PrintStream Arrays

I am trying to make a method that takes int[][] list and filename String outName as parameters, reads each list[i][j] entry and converts them to ascii character accordingly. This is what I have: public static void makeAscii(int[][] list, String…
Corp. and Ltd.
  • 401
  • 2
  • 5
  • 17
1
vote
1 answer

Adding a console output to Swing gui that can support special characters

My application has a console where all the system's printstream content is rerouted to. My application will also output special characters, specifically other languages (asian languages, Russian, Arabic, etc) I'm using a JTextArea as the console…
Andrio
  • 1,852
  • 2
  • 25
  • 54
1
vote
1 answer

PrintStream Error with no reason?

I am making a server client system in which the client will write a message to the server and the server will save it as a string and print it in the console. But when ever the System tries to read the line I get "PrintStream error" in the console.…
Alex
  • 13
  • 2
1
vote
1 answer

AOP with Springboot, java.io.PrintStream

built a simple springboot application with some aspects checking architecture and so on. i try to catch every call to System.out.println() to give warning about usage so that is what i've found so far: System.out.println() uses PrintStream so that…
Marcel Hinderlich
  • 213
  • 1
  • 3
  • 19
1
vote
1 answer

How to compare Numbers from a file with random numbers?

Hello everyone so this is the case. My lotto application works, but I just need a last thing to implement and I have a huuuuge problem with this. So I have 6 numbers saved in a "lotto.dat" file. 1, 2, 3, 4, 5, 6. If I don't choose to get new…
user3703289
  • 347
  • 1
  • 3
  • 9
1
vote
2 answers

how to get a console output (e.g. on eclipse) AND write/copy the same output to file?

I know that this type of question have been asked many times. But I didn't find any answer for myself. That's why i am asking once more. I have got an output on my console. I want to copy the same output 1-to-1 to a file. I don't want to redirect. I…
1
vote
2 answers

PrintStream unexpectedly moving to a new line?

I can't figure out why my code is causing the PrintStream to go to a new line: // displays the total time of the leak in months from the calculateLeakTime() method. String leakTime = LeakCalculator.calculateLeakTime(); …
Kevin Bright
  • 961
  • 2
  • 9
  • 17
1
vote
1 answer

Console output not working after method call

I'm currently working on an application that generates and validates .xml files based on some template files. The method I call to generate those files goes like this: FtlProcessingController ctrl = new…
Alexis Leclerc
  • 1,303
  • 1
  • 16
  • 26
1
vote
1 answer

"Cannot be applied to given types" Error during PrintStream

I'm not entirely sure what's going on with my code right now. I'm attempting to PrintStream it but I'm getting all sorts of errors regardless of what I do. import java.util.*; import java.io.*; public class Personality { public static void main…