Questions tagged [printwriter]

Java built-in class that prints formatted representations of objects to a text-output stream.

Public class PrintWriter extends Writer.

Prints formatted representations of objects to a text-output stream. This class implements all of the print methods found in PrintStream. It does not contain methods for writing raw bytes, for which a program should use unencoded byte streams.

Unlike the PrintStream class, if automatic flushing is enabled it will be done only when one of the println, printf, or format methods is invoked, rather than whenever a newline character happens to be output. These methods use the platform's own notion of line separator rather than the newline character.

Methods in this class never throw I/O exceptions, although some of its constructors may. The client may inquire as to whether any errors have occurred by invoking checkError().

Since: JDK1.1

Source: Oracle

821 questions
-3
votes
1 answer

I want to read a string array using bufferedreader

I have a Client class that sends a string array by using PrintWriter and the Server class is then supposed to be able to receive these values but I can't find a solution in reading from a string array. Client class: public Client(String[] data)…
phoenixWright
  • 77
  • 1
  • 12
-3
votes
2 answers

Java ArrayList names "Cannot Find Symbol" and "No Suitable Method" for PrintWriter

After looking around, I haven't been able to find either of these questions answered elsewhere. If they have been and I couldn't find them, please point me in the right direction. I use three ArrayLists in my program to store a customer's order…
David
  • 9
  • 5
-3
votes
1 answer

I can't print things into outfile

I can't seem to print what I want to print to the "transaction-list.txt" file. It did however create the file, but it prints nothing into it when the program is running. It suppose to worked seamlessly, just don't know why. Here's my code: final…
EDP
  • 1
  • 3
-3
votes
1 answer

Does a file have to be updated in some way for Java?

So I start with a textfile; this textfile at the start contains a number 3 (amount of woningen) 3 Woningen. I can read them with a Scanner without errors. I can also add a Woning without errors. If a Woning is added, the number on top of the file is…
Earless
  • 173
  • 2
  • 3
  • 9
-3
votes
1 answer

PrintWriter program

Im trying to write a program that will ask for the name of an input file and an output file. It will open the input file and create the output file. It will then read the input file and make a double-spaced copy of the input in the output…
-3
votes
4 answers

printWritter issue in Java

I have a question regarding to printWrttier with String output, here is my code: import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Scanner; public class Out { …
Wang Pei The Dancer
  • 171
  • 2
  • 5
  • 12
-4
votes
1 answer

How to write ArrayList data to text file in java

I m trying to write ArrayList data in to the Text file using this code: public PrintWriter w() { try { FileWriter f = new FileWriter("C:\\Users\\jon\\Desktop\\a.txt"); PrintWriter br = new PrintWriter(f); …
jon
  • 37
  • 6
-4
votes
1 answer

Concat numbers to write to file by printWriter

I wanted an output like: 9000000000 9000000001 9000000002 ... 9999999999 I started loop from a=9 but it printing from starting output it gives into the file starting from 0 to 9 and the continuing one by one. class Demo { public static…
-4
votes
1 answer

How can I output to the same txt file I used to input in java?

I want to "overwrite" what's in the input file and replace it with the updated information.
Ceelos
  • 1,116
  • 2
  • 14
  • 35
-5
votes
2 answers

Close printwriter from different class

Is it possible to close print writer from different class or is there any other way. What I am trying to do is there is a function "A" which is calling function "B" which calls function "C" and this function "C" is inside a loop. And all "A","B","C"…
-9
votes
2 answers

Write java array to file.txt in one line

What should I change in my code to write my array into text file in a single line instead of a different line per vale of the array? PrintWriter zapis = new PrintWriter("wyniki.txt"); for (int g=1; g<801; g++) { zapis.println(g+":"+wynik[g]+"…
Diana
  • 13
  • 2
1 2 3
54
55