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.
Questions tagged [bufferedwriter]
754 questions
2
votes
1 answer
Reliable saving JTextArea string in multi entry text file
I have a software that stores its data in multible nested data objects. On saving this project data, every instance gets an out handle (BufferedWriter) and writes its own data. Most data is single line and no problem, but there are a few multiline…

Frankie
- 31
- 3
2
votes
2 answers
Reuse an InputStream to a Process in Java
I am using ProcessBuilder to input and receive information from a C++ program, using Java. After starting the process once, I would like to be able to input new strings, and receive their output, without having to restart the entire process. This is…

Sam
- 45
- 5
2
votes
1 answer
Write Strings that contain \n with BufferedWriter
If I have a String that contains some words with here and there a \n in between,
is there a way to write them into a .txt file on separate lines? For example:
File myFile = new File("TextFile.txt");
FileWriter fw = null;
try {
…

Stijn
- 285
- 8
- 22
2
votes
4 answers
Slow BufferedWriter Performance
I have a method that writes 44 MB worth of data from a ResultSet to a CSV file. However, it is taking about 3.5 minutes to complete. This seems slow for only 44 MB of data. Can anyone see anything slowing down my code?:
public static void…

John Roberts
- 5,885
- 21
- 70
- 124
2
votes
0 answers
Problems when writing to a .txt file on Windows 10
I have created a program which generates primes (use the Sieve of Eratosthenes algorithm) and give the user an opportunity to choose where the results are outpuuted too; the console, a text file, or both.
When writing to the text file though, I am…

James
- 459
- 1
- 5
- 16
2
votes
1 answer
BufferedWriter writing random letters into file (Java)
For some reason when I am trying to write an int called duration to a file called newSession and the program is done compiling and I open the file located on my desktop, every other file is fine (meaning the content I wanted to be written to that…

Kappa
- 21
- 2
2
votes
1 answer
Why it is advisable to wrap a BufferedWriter around any Writer whose write() operations may be costly, such as FileWriters and OutputStreamWriters?
My question is, whether it is direct use, as shown below;
class Test{
public static void main(String args[]){
try{
FileWriter fo =new FileWriter("somex.txt");
int arr[] = {9};
for(int i =0; i

MKod
- 803
- 5
- 20
- 33
2
votes
1 answer
Writing to file in java using BufferedWriter
I'm trying to take some random samples from a file and do some operations and then write them to another file. But I'm having trouble writing to a file in the grepLine method which can be found below.
Inside the while loop of the grepLine function,…

Kaushik
- 553
- 3
- 11
- 27
2
votes
1 answer
BufferedOutputStream multiple lines Write in File
I have a little problem with a function I made.
I want that everytime I give a string to this function, it will save me to a new Line in the same file, but actually now is saving only the last string Im givving. It's like overwriting again and…

Nicholas
- 3,529
- 2
- 23
- 31
2
votes
2 answers
Java get line total then write to specific line
I'm stuck on writing to a specific line using File, BufferedReader, & BufferedWriter.
What I'm trying to achieve is getting my text files total line count (-3) & writing to that line.
Currently it just erases the whole file & nothing is…

Ryan
- 83
- 2
- 9
2
votes
1 answer
Why does this code cause Java to write over the data in a file?
I am not sure as to why the following code causes Java to override the data already in my file every time, when what I want it to do is actually write each new piece of data on a new line. I have included the relevant pieces of code (I understand…

James
- 338
- 1
- 2
- 16
2
votes
4 answers
Count the bytes written to file via BufferedWriter formed by GZIPOutputStream
I have a BufferedWriter as shown below:
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
new GZIPOutputStream( hdfs.create(filepath, true ))));
String line = "text";
writer.write(line);
I want to find out the bytes…

Junaid
- 768
- 8
- 13
2
votes
2 answers
Java: Having some problems with my file input/output (br cannot be resolved)
I'm relatively new to Java, so I'm just trying to get some practice with simple IO, as well as exception handling. My program is pretty basic - I just want to read a number from a file, and then convert it from Celsius to Fahreinheit, and output it…

user2411290
- 631
- 2
- 10
- 33
2
votes
0 answers
Program freezes during BufferedWriter operations - not reproducible
I use a Python 3.4 program to control a measurement setup with a Raspberry Pi. What the program does is the following:
- Send commands to a micro controller via COM port
- Receive data packages and parse them
- Write received data and some…

Thor
- 31
- 2
2
votes
2 answers
How to copy from one file to another but omit certain lines / which .write() to use?
I'm trying to create a modified version of a file by omitting certain lines from the original file if they do not meet a certain requirement. I'm not sure how to accomplish this. When I read in files, I use
BufferedReader(new FileReader(new…

user3025403
- 1,070
- 3
- 21
- 33