Java BasicsGeneral beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
How can I write into a file without replacing its content. For example edit
Hello World
to be
Hello All World.
Note: my original file is huge so I can not read, add, write.
I know what u mean , i had encountered the same problem where the data i was writing was getting overwritten . This tends to happen when the data to the file is written by several methods spread across a package . U can do one thing u can declare the BufferedWriter as a class variable .Then in the constructor initialize it to the file that u want to write . This can be used till the current object is in the scope
Now when u are done with the writing part u can close the file . Usually this should be done somewhere in the end of the main method to be safe .