@Test public void loadOnNonexistentFileFails() throws IOException { final Path randomFile = Files.createTempFile("other", ".txt").resolveSibling("non-existent.txt"); final Throwable throwable = catchThrowable(() -> loader.load(randomFile)); assertThat(throwable) .isNotNull() .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("doesn't exist or is not a file"); }
@Override public void load(final Path inputFile) throws IOException { if (!Files.isRegularFile(inputFile)) { throw new IllegalArgumentException(inputFile.toString() + " doesn't exist or is not a file"); } this.reader = Files.newBufferedReader(inputFile); final String firstKey; while (true) { final String line = reader.readLine(); if (line == null) { this.nextEntry = null; this.reader.close(); return; } if (line.startsWith(" ")) { firstKey = line; break; } } final String firstValue = reader.readLine(); this.nextEntry = new DataEntry( Base64.getDecoder().decode(Hex.decode(firstKey.trim())), new ByteArrayInputStream(Hex.decode(firstValue)) ); }
BdbDumpFile implements StoreLoader { @Override public void load(final Path inputFile) throws IOException { if (!Files.isRegularFile(inputFile)) { throw new IllegalArgumentException(inputFile.toString() + " doesn't exist or is not a file"); } this.reader = Files.newBufferedReader(inputFile); final String firstKey; while (true) { final String line = reader.readLine(); if (line == null) { this.nextEntry = null; this.reader.close(); return; } if (line.startsWith(" ")) { firstKey = line; break; } } final String firstValue = reader.readLine(); this.nextEntry = new DataEntry( Base64.getDecoder().decode(Hex.decode(firstKey.trim())), new ByteArrayInputStream(Hex.decode(firstValue)) ); } }
BdbDumpFile implements StoreLoader { @Override public void load(final Path inputFile) throws IOException { if (!Files.isRegularFile(inputFile)) { throw new IllegalArgumentException(inputFile.toString() + " doesn't exist or is not a file"); } this.reader = Files.newBufferedReader(inputFile); final String firstKey; while (true) { final String line = reader.readLine(); if (line == null) { this.nextEntry = null; this.reader.close(); return; } if (line.startsWith(" ")) { firstKey = line; break; } } final String firstValue = reader.readLine(); this.nextEntry = new DataEntry( Base64.getDecoder().decode(Hex.decode(firstKey.trim())), new ByteArrayInputStream(Hex.decode(firstValue)) ); }  }
BdbDumpFile implements StoreLoader { @Override public void load(final Path inputFile) throws IOException { if (!Files.isRegularFile(inputFile)) { throw new IllegalArgumentException(inputFile.toString() + " doesn't exist or is not a file"); } this.reader = Files.newBufferedReader(inputFile); final String firstKey; while (true) { final String line = reader.readLine(); if (line == null) { this.nextEntry = null; this.reader.close(); return; } if (line.startsWith(" ")) { firstKey = line; break; } } final String firstValue = reader.readLine(); this.nextEntry = new DataEntry( Base64.getDecoder().decode(Hex.decode(firstKey.trim())), new ByteArrayInputStream(Hex.decode(firstValue)) ); }  @Override void load(final Path inputFile); @Override DataEntry nextEntry(); }
BdbDumpFile implements StoreLoader { @Override public void load(final Path inputFile) throws IOException { if (!Files.isRegularFile(inputFile)) { throw new IllegalArgumentException(inputFile.toString() + " doesn't exist or is not a file"); } this.reader = Files.newBufferedReader(inputFile); final String firstKey; while (true) { final String line = reader.readLine(); if (line == null) { this.nextEntry = null; this.reader.close(); return; } if (line.startsWith(" ")) { firstKey = line; break; } } final String firstValue = reader.readLine(); this.nextEntry = new DataEntry( Base64.getDecoder().decode(Hex.decode(firstKey.trim())), new ByteArrayInputStream(Hex.decode(firstValue)) ); }  @Override void load(final Path inputFile); @Override DataEntry nextEntry();  }