javafilefileinputstreaminputstreamreader

Java, Reading a file that has UCS-2 Little Endian encodeing


I'm trying to read a txt file that has the UCS-2 LE encoding, I have the following code below. the ??? is the encoding variable I need but I am not sure what it's supposed to be.

InputStream HostFile = new FileInputStream(Location + FileName);
Reader file = new InputStreamReader(HostFile, Charset.forName(???);
PrintWriter writer = new PrintWriter(outLocation, "UTF-8");

Any ideas would be appreciated .


Solution

  • Reader file = new InputStreamReader(HostFile, Charset.forName("UTF-16LE");