I have been working with Files in Java. And I know the basics of reading and writing to/from files. Below is the code that I tried to write
void qlm(String option,String initiate,String ii,String file_path,String source,List destination){ //,String paths,String src){
String [] Ln = {"B","C","D"};
int count =1, counter=1,seq=1;
try{
System.out.println("Here: " +file_path);
PrintWriter pwr = new PrintWriter(new FileWriter(getHandleB()),true);
for(int i=0;i<Ln.length;i++){
pwr.println("Sequence_Number" + "|" + "QLM_Operation" + "|" + "II_D" + "|" + "Val_D" + "|" + "List" + "|" + "Type" + "|" + "Status" + "|" + "Source" + "|" + "Destination");
pwr.println(count + "|" + option + "|" + "DataK" + "|" + "Value" + "|" + Ln + "|" + "Null" + "|" + "Pending" + "|" + source + "|" + Ln[i]);
count++;
}
pwr.close();
getHandleB() is the path of the File. This is performed in the method qlm(parameters)
Now I want to write in the same File (path: getHandleB()) from a different method named handle(parameters)
The output of this function, should write in the same file without removing the contents of the previous method. When i try to write in the file, it removes the previous contents and writes the new one. How can I avoid this. I want all the contents from all the methods to be written. Thanks for all the help.