Questions tagged [printstream]

175 questions
0
votes
2 answers

How do I catch a java.io.PrintStream place its output in a JEditorPane?

I am attempting to make a Java program in which a user can select any .class or .jar file from their computer. My program will then pop up a JInternalFrame with a JEditorPane in it as the console, capturing any console output from the user's…
Ky -
  • 30,724
  • 51
  • 192
  • 308
0
votes
0 answers

SetOutputStream works with System.out but not with PrintStream

Using JavaFX I am trying to redirect Jsch session.SetOutputStream to a TextArea in a form of a PrintStream. PrintStream works as excepted except for the session output. TextArea PrintStream setup: ConsoleClass console = new…
Moe
  • 1,427
  • 4
  • 34
  • 54
0
votes
2 answers

Save received data in java

I have server that sends bmp file and a client in Android where I try to save the data that i received. I save the data in a file using the following code: ... byte[] Rbuffer = new byte[2000]; dis.read(Rbuffer); try { …
G.V.
  • 709
  • 2
  • 11
  • 17
0
votes
0 answers

Printing to a closed PrintStream does not display an exception

I'm trying to understand why printing to a closed PrintStream does not display a stream closed exception, the way FileOutputStream does. For example, the following code does not display an exception on Eclipse's console: public class Try { …
Gonen I
  • 5,576
  • 1
  • 29
  • 60
0
votes
2 answers

system.out redirection to jfx fextfield not showing scandinavian characters

I've been scratching my head for a few days now trying to figure out how to correctly encode scandinavian characters for use in a text field These three characters: Æ Ø Å ( æ ø å) show up as ���. meaning that the running this…
0
votes
2 answers

In Java, how does PrintStream end up printing text to the console?

So from my understanding, the PrintStream must use some sort of Java Native Interfacing to communicate with the Operating System so it can write to the standard output, or does java use some other technique? I would like to know as the JVM's…
TheRenegade
  • 127
  • 6
0
votes
1 answer

Why is my writefile() not compiling?

The writefile() method should write out to the given output file all the integers in the given array, one per line. For this part, the merge method should return a new array big enough to hold the content of the first two arrays (a and b), and then…
0
votes
1 answer

MavenCli doMain() method build log to LOGGER.info instead of System.out

I am using maven cli to run maven command from Java. Since the below method accepts only PrintStream object as input, how do I write maven build log to Logger instead of System.out. I am not trying to put all of system.out and system.err onto…
Upen
  • 1,388
  • 1
  • 22
  • 49
0
votes
1 answer

What is the benefit of using System.out.print over System.out.printf?

I have a question similar to Is there a good reason to use "printf" instead of "print" in java?. That question asks and is answered about the benefits of using System.out.print over System.out.printf. I am curious about the benefits to using…
Evorlor
  • 7,263
  • 17
  • 70
  • 141
0
votes
1 answer

How to change back to standard output console?

I tried to PrintStream to a text file for writing a bunch of output to a file. But after the file is created, I was trying to switch back to the standard output just to continue on with other processes, but I have no idea about doing that switch.…
Yamano
  • 3
  • 2
0
votes
4 answers

Creating method to replace "sir" with "dawg"?

I have made a program designed to run through a text document(Shakespeare's King Lear) and replace all instances of the letter s with z and "sir" with "dawg". I have the first method working, however I am having trouble figuring out what the problem…
0
votes
2 answers

File created with Eclipse but not with command line

I am using Java to create a file with some data in it. But I encouter a problem. Indeed I succeed in creating a file and write "hello" in it when I run from Eclipse. But when I export that code in a jar file and I tried to execute it in the command…
0
votes
1 answer

how to allow user to choose the name and location of a printstream file(Java)

I'm making a chess game, and I want to add saving functionality, I'm planning on outputting the file as a txt file that will contain all the information that the program will need to restore the games status, but I want it to be so that when the…
austinphilp
  • 57
  • 1
  • 9
0
votes
2 answers

File not created by using File.createNewFile();

im having a small problem with my properties files with a PrintWriter. This is the code for the main file: package org.goverment; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Tg { …
0
votes
2 answers

Where do i find the text file that print stream outputs to?

This is my code for writing to a file using print stream in java PrintStream stream = null; try { stream = new PrintStream(new File("hi.txt")); stream.println("hi my name is chris"); } catch…
committedandroider
  • 8,711
  • 14
  • 71
  • 126