As planned, the file should be read in utf-8 encoding, but it is read normally only in cp1251.

public static void main(String[] args) throws IOException { FileInputStream inFile = new FileInputStream("read.html"); byte[] str = new byte[inFile.available()]; inFile.read(str); String text = new String(str, "windows-1251"); byte[] b = text.getBytes("utf-8"); String t = new String(b, "utf-8"); File file = new File("write.html"); try { if(!file.exists()){ file.createNewFile(); } PrintWriter out = new PrintWriter(file.getAbsoluteFile()); try { out.print(t); } finally { out.close(); } } catch(IOException e) { throw new RuntimeException(e); } } 
  • one
    new PrintWriter(file.getAbsoluteFile(), "utf-8") ? - PetSerAl
  • Thanks a lot, helped - Iryna

0