I am having trouble while writing to file using the PrintWriter. Following is my code:
String abc = request.getParameter("textAreaField"); //String is "a b c" (with spaces)
String fileA = dir + "/A";
PrintWriter fileWriterA = new PrintWriter(new FileOutputStream(fileA,true));
fileWriterA.println(abc);
fileWriterA.close();
The problem I am having here is while writing to the file "A" in the directory "dir" only "a" from String abc will be written and the rest after the space is not written. String abc here in the code is coming from a textarea in html and I have the above code in my servlet. I am not able to understand why it won't write the string with spaces to file. I think it should. I have also checked by printing the String abc and it does print the string "a b c" (with spaces). But it won't print that to file. Is there a problem with my code? Any help would be appreciated.
Thanks in advance.