PrivateKeysHandler { public Collection<PrivateKeyAndDate> readInPrivateKeys(File importFile, CharSequence password) throws PrivateKeysHandlerException, KeyCrypterException { if (importFile == null) { throw new PrivateKeysHandlerException("Import file cannot be null"); } ArrayList<PrivateKeyAndDate> parseResults = new ArrayList<PrivateKeyAndDate>(); Scanner scanner = null; try { String importFileContents = readFile(importFile); if (importFileContents != null && importFileContents.startsWith(keyCrypter.getOpenSSLMagicText())) { KeyCrypterOpenSSL keyCrypter = new KeyCrypterOpenSSL(); importFileContents = keyCrypter.decrypt(importFileContents, password); } scanner = new Scanner(new StringReader(importFileContents)); while (scanner.hasNextLine()) { processLine(scanner.nextLine(), parseResults); } } catch (IOException ioe) { throw new PrivateKeysHandlerException("Could not read import file '" + importFile.getAbsolutePath() + "'", ioe); } finally { if (scanner != null) { scanner.close(); } } return parseResults; } PrivateKeysHandler(NetworkParameters networkParameters); void exportPrivateKeys(File exportFile, Wallet wallet, BlockChain blockChain, boolean performEncryptionOfExportFile, CharSequence exportPassword, CharSequence walletPassword); Verification verifyExportFile(File exportFile, Wallet wallet, BlockChain blockChain,
            CharSequence exportPassword, CharSequence walletPassword); Collection<PrivateKeyAndDate> readInPrivateKeys(File importFile, CharSequence password); Date calculateReplayDate(Collection<PrivateKeyAndDate> privateKeyAndDates, Wallet wallet); static String readFile(File file);  }
@Test public void testImport() throws Exception { NetworkParameters prodNet = NetworkParameters.prodNet(); PrivateKeysHandler privateKeysHandler = new PrivateKeysHandler(prodNet); assertNotNull(privateKeysHandler); File directory = new File("."); String currentPath = directory.getAbsolutePath(); String testDirectory = currentPath + File.separator + Constants.TESTDATA_DIRECTORY + File.separator + PRIVATE_KEYS_TESTDATA_DIRECTORY; String expectedPrivateKeysFile = testDirectory + File.separator + EXPECTED_TEST1_PRIVATE_KEYS_FILE; Collection<PrivateKeyAndDate> parsedPrivateKeysAndDates = privateKeysHandler.readInPrivateKeys(new File(expectedPrivateKeysFile), null); assertNotNull(parsedPrivateKeysAndDates); assertEquals(7, parsedPrivateKeysAndDates.size()); int count = 0; for (PrivateKeyAndDate privateKeyAndDate : parsedPrivateKeysAndDates) { assertEquals(EXPECTED_ADDRESSES_FOR_TEST1_WALLET[count], privateKeyAndDate.getKey().toAddress(prodNet).toString()); count++; } }