Text File writing in Java -


i writing string content text file in java code after writing saving file onto disk, getting incorrect encoding exception, please suggest me correct java code?

string content =filecontent;//filecontent.tostring(); system.out.println("file contt===>"+content);  file filewrite = new file("/homedesktop/normalfile/"+filename);  // if file doesnt exists, create if (!filewrite.exists()) {     filewrite.createnewfile(); } filewriter fw = new filewriter(filewrite.getabsolutefile()); bufferedwriter bw = new bufferedwriter(fw); bw.write(filecontent); bw.close(); 

ioutils.tostring(string) converts coding. string not encoded in utf-8

note: dont need this:

// if file doesnt exists, create if (!filewrite.exists()) { filewrite.createnewfile(); } 

file create automatically new file, if there isn't one.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -