BufferedReader Class trouble | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

BufferedReader Class trouble

so i have a program with a bufferedReader and a bufferedWriter that share a file in a folder. i set up the file using File A = new File(String path); now id i write to the file using the writer and then read it works fine, but if i delete the write lines and open the file manually and type some stuff in and save, after doing the read command I get null. I wrapped a file reader and writer with my bufferClasses, i just cant think of what the issue might be. any help would be appreciated https://code.sololearn.com/csq616LbHg0Q/?ref=app edit1: im starting to think that maybe instead of opening an existing file its creating a new File everytime, can anyone confirm this? and give a work around edit2: also this is not my full code, just the class thats causing the issue, i have ran debugger on it, if i place a write before the read it will show up with what was written but if i just try and use the file after saving stuff to it manually, it acts like an empty file

26th Oct 2018, 10:27 AM
Robert Atkins
Robert Atkins - avatar
1 Answer
+ 1
I have figured it out, indeed the new File constructor was generating a new file everytime, replacing the one i had saved with a new and empty one, so keep in mind when working with existing files creating a new file object with that name will replace your existing one.
26th Oct 2018, 12:43 PM
Robert Atkins
Robert Atkins - avatar