How to write new line character to a file in Java

In EDIT 2: while((line = bufferedReader.readLine()) != null) { sb.append(line); //append the lines to the string sb.append(‘\n’); //append new line } //end while you are reading the text file, and appending a newline to it. Don’t append newline, which will not show a newline in some simple-minded Windows editors like Notepad. Instead append the OS-specific … Read more

using fstream to read every character including spaces and newline

Probably the best way is to read the entire file’s contents into a string, which can be done very easily using ifstream’s rdbuf() method: std::ifstream in(“myfile”); std::stringstream buffer; buffer << in.rdbuf(); std::string contents(buffer.str()); You can then use regular string manipulation now that you’ve got everything from the file. While Tomek was asking about reading a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)