how to write to a file with \n (new line)?
Hi there,
I have the following method that reads a file's content and convert it into a string:
publicstatic String getFileContent(String fileName)throws IOException
{
File file =new File(fileName);
FileInputStream fileInputStream =new FileInputStream(file);
BufferedReader bufferedReader =new BufferedReader(new InputStreamReader(fileInputStream));
StringBuffer stringBuffer =new StringBuffer();
String line;
while ( (line=bufferedReader.readLine()) !=null )
{
stringBuffer.append(line+"\n");
}
return stringBuffer.toString();
}
I'm trying to write a method that writes a String to a file WITH THE NEW LINE. All classes I used (DataOutputStream, FileWriter, PrintStream...) do not force a new line (I get everything in one line)
I thought maybe I should change the "\n" in the line
stringBuffer.append(line+"\n");
but...didn't know what.
thanks for any advise

