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
-1
votes
1 answer
Rewriting specific Strings within a text file and appending the rest
I'm trying to append an array of strings onto my text file but I also want to rewrite the first line each time too.
This is how I save my text (I attempted to append):
public static void saveText (String[] studentArray, String assignArray [],…

Milo
- 43
- 4
-1
votes
2 answers
Separate a .txt file by empty line and copy into another .txt file
I've been searching the web but to no avail.
My problem is that I have one log text file that contains text like
2014-03-04 08:28:45 1WKkiT-0008Qr-M9 Message received from xx (1.2.3.41) T="q"
2014-03-04 08:28:45 1WKkiT-0008Qr-M9 Message was…

Sean O'Riordan
- 51
- 1
- 8
-1
votes
5 answers
Why does nothing write to my file?
I have a program that I am working on and I have an issue with writing a string into my file. The file is created, but the string value that should be written into it ultimately does not get written. There are no syntax errors according to Eclipse,…

Code4Fun
- 41
- 1
- 5
-1
votes
1 answer
Writing order string into text file
This is only write "test 2" in the text file.
How to write the first line will be "test 1", and the second line will be "test 2" in the text file.
if(s1.equals("test 1")&&s2.equals("test 2")){
…

Jarek Huang
- 119
- 3
- 17
-1
votes
1 answer
Save/Write encrypted Bytes from Cipher to a file
I am currently trying to encrypt and decrypt a String with Cipher. The problem i ran into is that I am trying to save the encrypted bytes to a file and after that decrypt them again. I am currently trying to do this with BufferedReader and…

Slashking
- 1
- 4
-1
votes
3 answers
Buffered Writer in Java not writing correctly
Im making a madlib program that opens a txt file then asks the user for data then presents a final madlib it shows up perfectly in the console but only the last line of the madlib appears in the text file please help this in Java btw.
FileWriter…
user2821614
-1
votes
1 answer
Small input trouble in a program in java
I have learnt about BufferedReader as well as BufferedWriter, so I decided to create a small text processor for the command line (meaning without interface, just in cmd/terminal). It asks a user for document name (Which will then create a file) and…

pavelexpertov
- 19
- 1
- 2
- 4
-1
votes
1 answer
Java space at start of text file
I have a program that ask the user for what application it want to open,
this is how the program works:
the user write what application it want to open in a "inputDialog" example the user write "Open application Notepad".
the program looks for the…

user1886564
- 1
- 1
- 2
-1
votes
1 answer
Exception in thread "main" java.lang.NullPointerException cann't write to a class
So I have this code :
package Firstpack;
import java.io.*;
import java.util.*;
public class Main {
public static void menu() {
System.out.println("Welcome");
System.out.println("1. Add a record ");
…

user1134746
- 71
- 4
- 9
-1
votes
1 answer
File fully populating
I have this piece of code that is supposed to insert data in a table and fill a txt file with the same data. However I am finding that the table is being filled with the appropriate 2019 rows but the file only contains 1639 with a [Incomplete last…

Mike
- 2,299
- 13
- 49
- 71
-2
votes
2 answers
How to use try-with-resources in nested function in java?
I noticed that if I don't call myBufferedWriter.close(), my content will not appear in the target file. What if the program ends accidentally before reaching myBufferedWriter.close()? How to avoid losing data that are already in the buffer but not…

John Smith
- 1
- 2
-2
votes
1 answer
BufferedWriter not writing data line by line
Currently trying to edit my old code from System.out.println() statements that display the results of a benchmark test to writing the results to 2 different .txt files. I am doing this so I can create a new program that uses JFileChooser to select…

GhostRider
- 1
- 1
-2
votes
2 answers
Delete old files before adding new files in directory java without using FileUtils
I am writing new files into a directory on daily basis.
BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\difftest\\newfiles\\"+decisionList.get(i)+"_"+i+".txt"));
Before creating new files, I want to delete the previously added files…

Richa Sharma
- 75
- 1
- 9
-2
votes
1 answer
How to ensure prompt output to the file with BufferedWriter?
I am writing to a text file in a while loop:
BufferedWriter writer = new BufferedWriter("...");
BufferedReader reader = new BufferedReader("...");
while((line = reader.readline()) != null){
....
writer.write(line +…

user697911
- 10,043
- 25
- 95
- 169
-2
votes
1 answer
create bunch of files in particular directory
I am trying to create lot of files in particular directory. If directory doesn't exist then it should create the directory and create bunch of files in it.
Whereever my program is running, it should create a "files" directory if it is not there and…

user1234
- 145
- 1
- 12