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
1
vote
1 answer

Java buffered writer wont write all data

public static void save() { BufferedWriter out = null; try { out = new BufferedWriter(new OutputStreamWriter(Gdx.files.external(file).write(false))); out.write(Double.toString(FinanceSystem.currentPlayerCash)); …
andy07070
  • 45
  • 1
  • 7
1
vote
2 answers

Unable to write to file in Android, Read-Only Filesystem

I am trying to write a file in Android. private void writeScoreToFile(BlastScore result) { try{ FileWriter fstream = new FileWriter(CaptureActivity.BLAST_SCORES,true); BufferedWriter out = new…
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556
1
vote
1 answer

Creating file in java

This may sound easy but I when debugging through this code it just stops debugging, can't work out if its throwing an exception or not. What am I doing wrong? Writer output = null; File file = new File("write.txt"); output = new BufferedWriter(new…
Ben Taliadoros
  • 7,003
  • 15
  • 60
  • 97
1
vote
1 answer

Passing a BufWriter to a function in Rust

In this example I'm trying to pass a BufWriter to some functions but don't understand generic type syntax enough to figure out whats missing. Instead of passing the file, I want to pass the buffered writer and could not find any examples of this…
Ross Youngblood
  • 502
  • 1
  • 3
  • 16
1
vote
0 answers

Why is my Java program creating a new file every time I call append?

I am new to file handling in Java. My input file is a csv file with a number of columns. My objective is to create a new file each time I encounter a different value in the input .csv file and append to it if the file already exists but the file is…
1
vote
1 answer

Write to File doesn't persist between activities

I'm writing and reading from a file and it works perfectly fine. However when the activity is switched or the app is closed it appears that the file is deleted or some such as null is returned when trying to read from the file. I believed it may be…
1
vote
1 answer

Why BufferedWriter is writing the data into the file partially?

I am trying to write a json file using this code: File f = new File("words_3.json"); if (!f.exists()) { f.createNewFile(); } if (fileWriter == null) fileWriter = new BufferedWriter(new…
eFortsHub
  • 28
  • 5
1
vote
1 answer

Why is the Scanner object affecting the BufferedWriter's ability to write to a file?

I'm trying to read the text contents off of a given URL, then print the contents, as well as write it to a text file using BufferedWriter. I need to include a code block that allows only 35 lines of text to be printed out at a time until the user…
1
vote
1 answer

BufferedWriter does not detect read only directory

I have a java application that reads and writes csv files. I have created a read only directory on my Mac that my application will try to write a csv file to. I did this with chmod 000. No file gets created but no error is thrown either.…
iansumm
  • 31
  • 4
1
vote
2 answers

Java BufferedWriter performance

I need to create large test files—near 3 GB. So I try to write for start only string "1"—to check performance and correctness. FileWriter fstream = new FileWriter("c:/out.txt"); BufferedWriter out = new BufferedWriter(fstream,10000000); for (int i =…
user710818
  • 23,228
  • 58
  • 149
  • 207
1
vote
1 answer

Buffer and File in Java

I'm new to java and I want to ask what's the difference between using FileReader-FileWriter and using BufferedReader-BufferedWriter. Except of speed is there any other reason to use Buffered? In a code for copying a file and pasting its content into…
1
vote
2 answers

Need to read each N line from each file from List

I have List of Paths, each path represents file with text lines - i.e. 10 lines in each file. My task is to read each first line from each file, then each second, each third and so on. Trying to do this with BufferedReader so far results in it…
eugene p
  • 9
  • 3
1
vote
2 answers

(JAVA/JAVAFX) Attempt to create and write to file only creates blank file

I am trying to create a GUI where the user fills in TextFields and then the program creates a txt file and writes to it accordingly. Currently, the program creates the file with specified name, but without writing anything to it(the txt file is…
1
vote
1 answer

Why BufferedWriter is not writing into the file over the opened FileChannel?

Below is my code. I am able to successfully read the file. But not able to re-write onto it with the replaced content using BufferedWriter. But can do it with ByteBuffer. Any suggestions please where I am going wrong. myFile.txt…
raikumardipak
  • 1,461
  • 2
  • 29
  • 49
1
vote
1 answer

Only last record is being written to the json File when I am trying to write every record in the same file

I debugged and found out that the file is getting re-written after every iteration. Also, if I don't close the file nothing is getting written to the file. I am using BufferedWriter - do we need to close the file explicitly or it takes care of…
GKr297
  • 185
  • 2
  • 16