private String readTextFileToString(String filePath) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), "windows-1251"))) { // русский текст
StringBuilder sb = new StringBuilder();
String line;
while ((line = reader.readLine()) != null)
sb.append(line);
return sb.toString();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}