Questions tagged [bufferedwriter]

Java class for writing text to a character-output stream, buffering characters so as to provide for the efficient writing of single characters, arrays, and strings.

754 questions
2
votes
1 answer

Java Buffered Writer

File file = new File("result.csv"); FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); What happens if we do not close the buffered writer object after the write completion? I mean what if we miss…
jibs
  • 120
  • 1
  • 4
  • 15
2
votes
3 answers

Writing to a file with accented char

I'm using something like this in a java application to write to a file: BufferedWriter out = new BufferedWriter(new FileWriter(out1, true)); //where out1 is a File. When I run it from netBeans the output is good. When I try to run it from the…
nervousDev
  • 72
  • 9
2
votes
2 answers

Flush on Java application exit

Suppose a Java application writes to a file using BufferedWriter API (and does not call flush after every write). I guess that if the application exits with System.exit the buffer is not flushed and so the file might be corrupted. Suppose also that…
Michael
  • 41,026
  • 70
  • 193
  • 341
2
votes
2 answers

Java socket polling for checking if client is available

I am trying to poll a socket on server side to check if client is still available. I checked a few threads here but nothing seems to work. As I found out there is no direct way of checking that so I tried to perform write opperation to socket and...…
Tomasz Łoś
  • 79
  • 2
  • 10
2
votes
1 answer

JTextArea to file

I want to save text from a JTextArea to a file, the code below works perfectly fine but the only thing is that the line breaks aren't converted. This means no matter how many lines I have in the JTextArea, they are all displayed in one line in the…
Assim
  • 441
  • 2
  • 6
  • 18
2
votes
3 answers

Replace a character in a BufferedWriter

I am creating a text file using BufferedWriter BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("/home/user/temp.txt")); /* Add Contents using bufferedWriter.write() */ At certain places while adding contents I…
Sangeet Menon
  • 9,555
  • 8
  • 40
  • 58
2
votes
2 answers

Why are parentheses needed for try/catch block BufferedWriter

I'm writing some code using java.io.BufferedWriter the first thing I tried was: String filename = new String("test.txt"); Charset charset = new Charset("US-ASCII"); try { BufferedWriter bw =…
jameh
  • 1,149
  • 3
  • 12
  • 20
2
votes
1 answer

JAVA: IO Exception: Reason Stream closed

Why am I getting the following exception? What I am doing is writing a giant ArrayList line by line to a file onto the disk. The file generated is about >700MB. It seems like it has some problem when written line by line. Could the size of the file…
Bob
  • 991
  • 8
  • 23
  • 40
2
votes
3 answers

BufferedWriter is acting strange

I am trying to make a game with a working highscore mechanism and I am using java.io.BufferedWriter to write to a highscore file. I don't have an encryption on the highscore and I am using Slick2D and LWJGL for rendering and user input. The program…
SuperCheezGi
  • 857
  • 3
  • 11
  • 19
2
votes
2 answers

BufferedWriter won't write all of the data to a file

So I wrote a program that is suppose write the contents of two LinkedList into a text file in the format "header line 1" "header line 2" "header line 3" x1 y1 x2 y2 x3 y3 ... x1023 y1023 Here is the main writing code: LinkedList
Lee Chen
  • 23
  • 1
  • 3
2
votes
1 answer

Java - BufferedWriter not writing (after flush())

ANSWER: You cannot write an int directly to a file. Convert it to a string first. Original Question: I know that this may sound like a nooby question, but I have nowhere else to turn. I'm trying to make Java write the Epoch (timestamp) to a…
user569322
1
vote
2 answers

BufferedReader/BufferedWriter Output line by line

I have the following problem: I need to input a file with 12 lines. Each line consist of 8 characters. I have to output it in a file with 8 lines and 12 characters. I have to read the input line by line and output each line at the same time. So I'm…
user1242750
  • 13
  • 1
  • 1
  • 4
1
vote
2 answers

Saving the text from an EditText

I'm trying to save the text from an EditText, I got it working, but I don't think I'm doing it correctly. When I reopen it in my app it's fine, but when I pull it from the device and I open it in windows notepad I lose the line-breaks. ... …
bwoogie
  • 4,339
  • 12
  • 39
  • 72
1
vote
1 answer

Java Servlet writing form input to CSV

I am trying to build a servlet that parses form input and creates a .csv file from them, but the bufferedWriter object truncates a lot of characters for no (apparent to me) reason. String filepath = getServletContext().getRealPath("\\") +…
Spyros Mandekis
  • 984
  • 1
  • 14
  • 32
1
vote
3 answers

BufferedWriter - Stream closed prematurely during program execution

I am defining a buffered writer in a class I am developing, but having problems with it. In the class constructor I am defining: public class RestHandler { public static BufferedWriter rest_logger; public RestHandler(parsedXMLConfigData _config,…
Michael A
  • 5,770
  • 16
  • 75
  • 127