Читает весь файл в строку @param path путь к файлу @return строка с содержимым файла @throws IOException
(String path)
| 40 | * @throws IOException |
| 41 | */ |
| 42 | public static String readFile(String path) throws IOException { |
| 43 | try (FileInputStream stream = new FileInputStream(new File(path))) { |
| 44 | FileChannel fc = stream.getChannel(); |
| 45 | MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, |
| 46 | fc.size()); |
| 47 | return Charset.forName("UTF8").decode(bb).toString(); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Замена File.renameTo |
no test coverage detected