

Using the readLine() method of the BufferedReader object read the contents of the file. The value for the Charset could be StandardCharsets.UTF_8 or, StandardCharsets.UTF_16LE or, StandardCharsets.UTF_16BE or, StandardCharsets.UTF_16 or, StandardCharsets.US_ASCII or, StandardCharsets.ISO_8859_1Ĭreate/get an object of the Path class representing the required path using the get() method of the class.Ĭreate/get a BufferedReader object, that could read UtF-8 data, bypassing the above-created Path object and StandardCharsets.UTF_8 as parameters.

The new bufferedReader() method of the class accepts an object of the class Path representing the path of the file and an object of the class Charset representing the type of the character sequences that are to be read() and, returns a BufferedReader object that could read the data which is in the specified format. ("Contents of the file: "+buffer.toString()) Reading UTF data from the DataInputStream Instantiating the DataInputStream classĭataInputStream inputStream = new DataInputStream(fileIn) Instantiating the FileInputStream classįileInputStream fileIn = new FileInputStream("D:\test.txt") StringBuffer buffer = new StringBuffer()

Read UTF data from the InputStream object using the readUTF() method. Instantiate the DataInputStream class bypassing the above created FileInputStream object as a parameter. Instantiate the FileInputStream class by passing a String value representing the path of the required file, as a parameter. The readUTF() method of the java.io.DataOutputStream reads data that is in modified UTF-8 encoding, into a String and returns it. It is a fixed-width format and is always 1 "long" in length. UTF-32 − It comes in 32-bit units (longs). UTF-16 − It comes in 16-bit units (shorts), it can be 1 or 2 shorts long, making UTF16 variable width. UTF-8 − It comes in 8-bit units (bytes), a character in UTF8 can be from 1 to 4 bytes long, making UTF8 variable width. if you want to create documents that use characters from multiple character sets, you will be able to do so using the single Unicode character encodings. It is developed by The Unicode Consortium. Unicode (UTF) − Stands for Unicode Translation Format. There are various coding schemes available specifying the set of bytes represented by each character. In general, data is stored in a computer in the form of bits (1 or, 0).
