private static boolean checksumLocalTest(Path localPath, String checksum) { String crcPath = localPath.toString() + ".crc"; if (Files.isReadable(java.nio.file.Paths.get(crcPath))) { try { List<String> lines = Files.readAllLines(java.nio.file.Paths.get(crcPath), Charset.forName("UTF-8")); for (String line : lines) { if (line.equals(checksum)) { return true; } } } catch (Exception e) { return false; } } return false; }
private static boolean writeChecksum(Path localPath, String checksum) { try { java.io.BufferedWriter writer = Files.newBufferedWriter( java.nio.file.Paths.get(localPath.toString() + ".crc"), Charset.forName("UTF-8")); writer.write(checksum); writer.flush(); writer.close(); return true; } catch (Exception e) { logger.warn("Unable to write CRC file!"); return false; } }