Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Include a specific error, task, problem, or question in your title

java

Best Answer Unkish, 03 January 2016 - 08:13 AM

Path path = FileSystems.getDefault().getPath("logs", "access.log");
BufferReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_16);
Go to the full post


This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1 prashantsavadi

prashantsavadi

    CC Lurker

  • New Member
  • Pip
  • 3 posts

Posted 26 December 2015 - 10:05 PM

Can anyone tell me how read UTF-16 encoded file in java 7.

 

I am trying read UTF-16 encoded file in JDK 7, can anyone help me out. I can able to read in Python by:
 
fread = open(r'sample.dat', 'rb').read()
mytext = fread.decode('utf-16')
print mytext
I tried so many ways in java 7 but not succeeded. Thanks in advance.


#2 Unkish

Unkish

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 50 posts

Posted 03 January 2016 - 08:13 AM   Best Answer

Path path = FileSystems.getDefault().getPath("logs", "access.log");
BufferReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_16);