Text files may contain 8-bit chars, 16-bit chars or even 32-bit chars encoded as 8-bit surrogates.
Lines are terminated by the misnamed line.separator string which you can discover with
There should be a terminator on the last line, even though system property name line.separator suggests there should not. Putting the terminator there will not be treated as a final empty line. Programs will usually still work if the final terminator is missing, but in earlier versions of Java readLine would not read the last line without it.
There is no mechanism to keep track of which encodingwas used to write a text file. You just have to know. The Encoding Recogniserwill help you guess. Originally this caused no problem, because people rarely exchanged files except with coworkers. Everyone’s files were encoded in the same local national encoding. Today people share files all over the globe. It is best to use ASCII (American Standard Code for Information Interchange) for 7-bit chars, ISO-8859-1 for 8-bit and UTF-8 for 16-bit.
The classes to write text files include File, FileOutputStream, OutputStreamWriter and BufferedWriter. The classes to read text files include File, FileInputStream, InputStreamReader and BufferedReader. The File I/O Amanuensis will generate Java code for you to read and write text files (as well as other types).
Other ways of storing text include:
This page is posted
Optional Replicator mirror
Your face IP:[18.104.22.168]
You are visitor number|