Questions tagged [printstream]
175 questions
0
votes
0 answers
java printstream to pages file
Im hallway through my java course and Im learning how to write programs that save information to files. The code written below actually works fine when I run it only problem is that When i try to open the pages file after writing to it pages cannot…

John
- 21
- 5
0
votes
1 answer
Closing Scanner/PrintStream in finally-block which are declared in try-block
I am trying to close a Scanner and a PrintStream in a finally-block, which are declared in a try-block. The problem is, if the try-block fails because of an exception, the Scanner and Printstream are never declared, resulting in an error in the…

PISS_RANDOM
- 3
- 3
0
votes
1 answer
A PrintStream that does nothing
I am trying to make a PrintStream that does nothing every time its methods are invoked. The code has no error apparently, but when I try to use it I get a java.lang.NullPointerException: Null output stream. What am I doing wrong?
public class…

Asghabard
- 191
- 13
0
votes
1 answer
Sonar issue for printStream constructor as "Remove this use of constructor" for PrintStream(outStream);
I am generating CSR using java code, I have taken the code from online website journaldev.com
public byte[] generateCSR(final String sigAlg, final PublicKey publicKey, final PrivateKey
privateKey, final String organisationUrl) {
final…

SurendraKumar Jaiswal
- 192
- 1
- 17
0
votes
1 answer
Printing Console to JFrame TextArea - acts weirdly (flashing screen)
I have a project which prints out numbers line by line in Console and I successfully redirected this to my GUI Jframe I use for this application. However, when the numbers get printed into the TextArea, they do not show up nicely one by one like a…

Marek Ševela
- 97
- 10
0
votes
3 answers
Catching results from a void method into an output file
I am new at Java so thank you for helping!
public static int convert (String value) {
int temp_convert = 0;
// Setting up new Scanner to read the User-input string
Scanner token = new Scanner(value);
// Take out the word…

Hoa Ngoc Quynh Le
- 15
- 5
0
votes
1 answer
Only output partial result with PrintStream
Please take a look at my code.
import java.util.*;
import java.io.*;
public class LibraryDriver {
public static void main(String[] theArgs) {
String theAuthor = "";
String theTitle = "";
Scanner input = null;
…

DONGYANG TAO
- 1
- 1
0
votes
0 answers
Using PrintStream in PrintWriter formatting error
I'm fiddling with a basic code that utilizes methods to create values, and I want it to write into a text file and format the values, however the \n in my printf statements will not actually indent the solution.
File surfaceG = new…

Jordan L
- 1
0
votes
0 answers
Is there an exception-throwing substitute for JAVA's System.out.println and other PrintStream methods?
I have already read "Java: Why don't the PrintWriter or PrintStream classes throw exception?" but I am not interested in the reasons/excuses why those classes do not throw exceptions on output errors.
What I want to know is how to actually make them…

Guenther Brunthaler
- 727
- 5
- 12
0
votes
2 answers
PrintWriter autoflush puzzling logic
public PrintWriter(OutputStream out, boolean autoFlush):
out - An output stream
autoFlush - A boolean; if true, the println, printf, or format methods
will flush the output buffer
public PrintStream(OutputStream out, boolean autoFlush):
out -…

leventov
- 14,760
- 11
- 69
- 98
0
votes
1 answer
How to append new line in an existing file?
How am I supposed to append a new line after I finish adding what I am supposed to.
I have the following code:
try{
String textToAppend = question+userInput+","+typeOfAnswer;
Files.write(Paths.get("save.txt"),…

Ryk
- 123
- 7
0
votes
1 answer
PrintStream cannot be resolved to a type. Why?
PrintStream ps1, ps2;
My compiler tells me that
PrintStream cannot be resolved to a type
Why? This is my professor's code. Why doesn't it work? I thought you could use PrintStream as a type so that you can also write ps1=System.out for example.

user10568310
- 29
- 6
0
votes
1 answer
Hook into PrintWriter and modify the string
how to change the String of printwriter out.print before it print on the screen
i test it for system.out.print it works but i m in J2EE environment
image description

mr scams
- 1
- 2
0
votes
1 answer
Eclipse says PrintStream never closed even though it is closed
Should i close PrintStream only with try/catch/finally blocks or is there another way?
Or is this a bug in the IDE?
public void writeData(String fileDir) throws IOException{
FileOutputStream fos = new FileOutputStream(fileDir);
PrintStream…

Pionix
- 413
- 2
- 8
0
votes
2 answers
get list of active system.out printstreams
I was trying to use System.out.println to help with debugging and I found that it wasn't printing to the console. On inspection I found that my program had created 4 output consoles ( one for Java DB processes, one for the DB server, one for…

gristy
- 487
- 1
- 3
- 7