When writing data from the console to a file, the encoding is lost. 
package com.mycompany.praktika; import static j2html.TagCreator.*; import java.io.BufferedReader; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintStream; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class MainClass { static Scanner sc = null; static String name = null, region = null, first = null, second = null, name2 = null, three=null, firstname=null, secondname=null, threename=null, add=null,add2=null; static String ipn, scor, ipn2, scor2, prise, ipn3; public static void main(String[] args) throws IOException{ sc =new Scanner(new InputStreamReader(System.in)); System.out.println("---ОДЕРЖУВАЧ---"); first = ("---ОДЕРЖУВАЧ---"); System.out.println("Найменування: "); name = "Найменування: " + sc.next(); System.out.println("Регіон оплати: "); region = "Регіон оплати: " + sc.next(); System.out.println("ІПН: "); ipn = "ІПН: " + ifNotNumber(sc.next()); System.out.println("Номер рахунку: "); scor = "Номер рахунку: " + ifNotNumber(sc.next()); System.out.println("---БАНК ОТРИМУВАЧА---"); second = "---БАНК ОТРИМУВАЧА---"; System.out.println("Найменування: "); name2 = "Найменування: " + sc.next(); System.out.println("ІПН: "); ipn2 = "ІПН: " + ifNotNumber(sc.next()); System.out.println("Номер рахунку: "); scor2 = "Номер рахунку: " + ifNotNumber(sc.next()); System.out.println("Зняти з рахунку: "); prise = "Зняти з раххунку: " + ifNotNumber(sc.next()); System.out.println("---ДЕТАЛІ ПЛАТЕЖУ---"); three = "---ДЕТАЛІ ПЛАТЕЖУ---"; System.out.println("ІПН організіції/отримача: "); ipn3 = "ІПН організіції/отримача: " + ifNotNumber(sc.next()); System.out.println("Ім'я: "); firstname = "Ім'я: " + sc.next(); System.out.println("Фамілія: "); secondname = "Фамілія: " + sc.next(); System.out.println("По-батькові: "); threename = "По-батькові:" + sc.next(); System.out.println("Адреса платника: "); add = "Адреса платника: " + sc.next(); System.out.println("Телефон платника: "); add2 = "Телефон платника: " + sc.next(); String fina = first + "\n" + name +"\n" +region + "\n"+ ipn+ "\n"+ scor +"\n" + second + "\n" + name2 + "\n"+ipn2 + "\n" + scor2 + "\n" + prise + "\n" + three + "\n" + ipn3 + "\n" +firstname + "\n" + secondname+"\n" + threename + "\n" + add + "\n" + add2; createDocx(html( head( meta().withCharset("UTF-8"), title("Чек") ), body( style("display: table-row-group;"), h5(first).attr("style = \" display: table-row-group; \" ;"), h5(name).attr("style = \" display: table-row-group; \" ;"), h5(region).attr("style = \" display: table-row-group; \" ;"), h5(ipn).attr("style = \" display: table-row-group; \" ;"), h5(scor).attr("style = \" display: table-row-group; \" ;"), h5(second).attr("style = \" display: table-row-group; \" ;"), h5(name2).attr("style = \" display: table-row-group; \" ;"), h5(ipn2).attr("style = \" display: table-row-group; \" ;"), h5(scor2).attr("style = \" display: table-row-group; \" ;"), h5(prise).attr("style = \" display: table-row-group; \" ;"), h5(three).attr("style = \" display: table-row-group; \" ;"), h5(ipn3).attr("style = \" display: table-row-group; \" ;"), h5(firstname).attr("style = \" display: table-row-group; \" ;"), h5(secondname).attr("style = \" display: table-row-group; \" ;"), h5(threename).attr("style = \" display: table-row-group; \" ;"), h5(add).attr("style = \" display: table-row-group; \" ;"), h5(add2).attr("style = \" display: table-row-group; \" ;") ) ).render()); } static String ifNotNumber(String number){ try{ if (Double.parseDouble(number) >= 0) {} }catch(Exception e){ System.out.println("Введені не вірні данні: введіть знову"); ifNotNumber(sc.next()); return number; } return number; } public static void createDocx(String fina) throws IOException{ // HtmlCreator ht = new HtmlCreator(); //FileOutputStream fs = new FileOutputStream("Chek.html", StandardCharsets.UTF_8); OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream("Chek.html"), StandardCharsets.UTF_8); // OutputStreamWriter writer = new OutputStreamWriter(fs, StandardCharsets.UTF_8); writer.write(fina); writer.close(); } }