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
3
votes
5 answers

Java writing a list of strings to a file, but the file is empty

I have found this question in other languages, but have yet to find a solution to this issue in a java application. I have a large .txt file with millions of records. Each record is /n delimited. Basically it is a single column of data from a table.…
Jeremy
  • 326
  • 4
  • 15
3
votes
2 answers

Does BufferedWriter's write(String S) method actually buffer?

As per the Java SE 8 Documentation, the BufferedWriter class has the following methods of its own(w.r.t writing data): write(char[] cbuf, int off, int len) write(int c) write(String s, int off, int len) As I confirmed from checking the source code…
Nilashish C
  • 375
  • 2
  • 11
3
votes
2 answers

Append to a certain part of a text file in Java

I have an assignment where I have created a program to sell and order electronic devices and update two text files whenever a new sale/order has been made. I found a way to update the text file instead of overwriting it so any old orders/sales are…
Dimi
  • 31
  • 3
3
votes
3 answers

Character corruption going from BufferedReader to BufferedWriter in java

In Java, I am trying to parse an HTML file that contains complex text such as greek symbols. I encounter a known problem when text contains a left facing quotation mark. Text such as mutations to particular “hotspot” regions becomes mutations to…
Mikhail
  • 7,749
  • 11
  • 62
  • 136
3
votes
5 answers

Writing multi-dimensional array into text file file

I have a task which involves passing array values (writing) into a text (.txt) file in Java. This is my first time using BufferedWriter and I've tried quite a few variations on if statements, but can't see to get my program to write in the format…
Cyka bLyat
  • 35
  • 1
  • 5
3
votes
2 answers

Advantages of Double BufferedWriter or BufferedReader

I know that a BufferedWriter or BufferedReader cannot directly communicate with a file. It needs to wrap another Writer object to do it. Like, BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("abc.txt")); Here we are simply…
Aritra Roy
  • 15,355
  • 10
  • 73
  • 107
3
votes
1 answer

ArrayList and BufferedReader Note Taking Program

I have created a simple program that takes a title and a note which you enter then you have a choice to export the notes to txt file using BufferedWriter however because each note is a object which is stored in a ArrayList when storing them I…
dijam
  • 658
  • 1
  • 9
  • 21
3
votes
1 answer

Android File to String

I want to read out a file in Android and get the content as a string. Then I want to send it to a server. But for testing I just create a file on the device and put the content into it: InputStream stream =…
3
votes
4 answers

BufferedWriter, FileWriter, Output Stream...What's the most modern way to do these things?

I'm trying to programically create a new a file in java, and write a string array to that file. If the file already exists, I just want to append another string array (This is like a log file). Whats the most 'modern' way to do something like this?…
stepheaw
  • 1,683
  • 3
  • 22
  • 35
3
votes
2 answers

Using BufferedWriter to write to a string

I am trying to use a BufferedWriter to switch between writing to a File and writing to a String, but I have never used a BufferedWriter to write to anything but a file. Take this compilable code: public static void main(String[] args) { try…
ryvantage
  • 13,064
  • 15
  • 63
  • 112
3
votes
1 answer

Java 6 Copy files with readline

I try to copy files with some mandatory parameters : inputEncoding, outputEncoding and outputLineSeparator. But when I run my following code, my file with the CRLF final char is not well copy, this last CRLF char disapear. I think readLine return…
Damien
  • 31
  • 3
3
votes
3 answers

Update text file with BufferedWriter

I am writing to a text file using a BufferedWriter but the BufferedWriter does not write to the file until the program I'm running is finished and I'm not sure how to update it as the BufferedWriter is supposedly writing. Here is some of my code…
Brandon
  • 41
  • 2
  • 5
3
votes
2 answers

Why is BufferedWriter not writing to file?

I have this code: String[] strings = {"Hi" , "You", "He", "They", "Tetrabenzene", "Caaorine", "Calorine"}; File file = new File("G:\\words.txt"); FileWriter fWriter; BufferedWriter bWriter; try { if((file.exists())) { …
user3210944
  • 57
  • 1
  • 6
3
votes
1 answer

How to confirm packets arrived to the client from server?

What is the best way to know if a message has arrived on client? I'm using a BufferedWriter to send a message and it sends away the message. I could use an answer from the client and read it on the server, but I would like something faster Socket…
user2581137
3
votes
3 answers

Using FileWriter and BufferedWriter clearing file for some reason?

For some reason, when I create a new BufferedWriter and FileWriter in my program (Even if I haven't used it to write anything yet), it clears the file I have selected of all it's text. selectedFile is determined by a JFileChooser. public static File…
None None
  • 147
  • 2
  • 3
  • 11