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
4
votes
1 answer

Effect of frequent sdcard writes

In my chat app, I am adding the ability to log chats. The logs are saved on the sdcard and one BufferedWriter is kept open for every person/channel chat is done with. I'm wondering what effects this might have have on the sdcard and its life. My…
Al.
  • 2,285
  • 2
  • 22
  • 30
4
votes
3 answers

File Not Found Exception using Java FileWriter

I am trying to write to a txt file from a JAVA Application. I have tried using Buffered Writer, then just FileWriter to create a new file within a potentially new (not indefinitely since more files with different names will be later programatically…
Alexis R Devitre
  • 288
  • 2
  • 6
  • 21
4
votes
2 answers

Does java.io.FileWriter buffer bytes before writing to the output stream

As per java docs, In general, a Writer sends its output immediately to the underlying character or byte stream. Unless prompt output is required, it is advisable to wrap a BufferedWriter around any Writer whose write() operations may be…
Kumaran
  • 309
  • 4
  • 11
4
votes
4 answers

Bufferedwriter works, but file empty?

I have the following code: CSVmaker(LinkedList data) { String [] myLines = makeStrings(data); // for (int k = 0; k
newnewbie
  • 993
  • 2
  • 11
  • 26
4
votes
2 answers

Java BufferedWriter can't write certain characters

I decided to do a test for how many different characters I could write. I tried this code: for (int i = 0;i < 255;i++) { myBufferedWriter.write(i); } But in the file, using my hex editor, I saw it counted normally at first 01, 02, 03..., but…
Susan Yanders
  • 854
  • 1
  • 9
  • 18
4
votes
2 answers

"\n" not working when exported to .jar file

I have an output file for a program I have written. It is written by a FileWriter and BufferedWriter. FileWriter errout = new FileWriter(new File("_ErrorList.txt")); BufferedWriter out = new BufferedWriter(errout); Later I write to the…
user1816892
  • 85
  • 3
  • 8
4
votes
5 answers

Good practice in Java File I/O

I am trying to read integers from a file, apply some operation on them and writing those resulting integers to another file. // Input FileReader fr = new FileReader("test.txt"); BufferedReader br = new BufferedReader(fr); Scanner s = new…
Happy Mittal
  • 3,667
  • 12
  • 44
  • 60
4
votes
3 answers

Java Read / Write To File - BufferedReader BufferedWriter

This is a code snippet but basically what I want to do is read from a file named 'listings.txt' and write to a file named 'overview.txt'. I want to take the information out of 'listings.txt' and put them into 'overview.txt' as is (I will figure out…
RedHatcc
  • 3,016
  • 4
  • 16
  • 13
3
votes
1 answer

When I run the class, it produces a 0kb blank file. Can someone point out where I am mistakened?

I try to write something into the filename "aq.txt". There is no problem with the directory. FileOutputStream fos= null; try{ String xyz= "You should stop using xyz"; fos= new FileOutputStream("aq.txt"); Writer wrt= new…
Deepak behera
  • 651
  • 1
  • 5
  • 8
3
votes
2 answers

new PrintWriter(new BufferedWriter(new PrintWriter(s.getOutputStream, true)))

I am wondering is it possible to do new PrintWriter(new BufferedWriter(new PrintWriter(s.getOutputStream, true))) in Java where s is a Socket? Because it's impossible to create a BufferedWriter from an outputstream, I have wrapped the…
user700996
  • 463
  • 2
  • 10
  • 18
3
votes
1 answer

copying the content of two linkedlists into a text file in java

I have two linkedlists A1 and A2, both contain very long strings. I want to paste these strings for both linkedlists in one file i am using this function: private static void append(LinkedList A1, LinkedList A2) { try{ BufferedWriter outC = new…
infoSyStem
  • 145
  • 1
  • 2
  • 14
3
votes
4 answers

Deferring BufferedWriter.write to another thread

I have an event processing scheme which should also eventually write to file; I cannot afford to delay the event when the file is being flushed, i.e. waiting to the end of BufferedWriter.write(String). I'm looking for the easiest way to achieve that…
Dani
  • 4,267
  • 4
  • 29
  • 37
3
votes
5 answers

In Java, what is the difference between using a BufferedWriter or writing straight to file?

Possible Duplicate: In Java, what is the advantage of using BufferedWriter to append to a file? The site that I am looking at says "The BufferWriter class is used to write text to a character-output stream, buffering characters so as to provide…
Slerig
  • 95
  • 1
  • 9
3
votes
3 answers

Java BufferedWriter Write method

I am creating a CSV file using BufferedWriter from a ResultSet object. A few of the database columns hold null values. When I call obj.write(rs.get()) I am getting a NullPointerException when the output is null. Is there any other class other than…
NewBee
  • 228
  • 4
  • 14
3
votes
5 answers

BufferedReader to BufferedWriter

How can I obtain a BufferedWriter from a BufferedReader? I'd like to be able to do something like this: BufferedReader read = new BufferedReader(new InputStreamReader(...)); BufferedWriter write = new BufferedWriter(read);
Smith
  • 31
  • 1
  • 1
  • 2