FTPUtil { public static String extractFootPrint(String message) { String findText = "RSA key fingerprint is "; String returnMessage; if (!message.contains(findText)) return ""; String message1 = message.substring(message.indexOf(findText) + findText.length(), message.length()); returnMessage = message1.substring(0, message1.indexOf("\nAre you sure you want to continue connecting?")); return returnMessage.trim(); } private  FTPUtil(); static List<String> getKnownFootPrints(); static void addToKnownFootPrints(String footPrint); static String extractFootPrint(String message); static final String KNOWN_HOSTS_FILE; }
@Test public void testExtractFootPrint() throws Exception { String message="The authenticity of host '192.168.56.101' can't be established.\n" + "RSA key fingerprint is 2b:e0:2b:60:e7:63:9d:8d:06:da:53:f8:b8:27:b0:5f.\n" + "Are you sure you want to continue connecting?"; assertEquals(FTPUtil.extractFootPrint(message),"2b:e0:2b:60:e7:63:9d:8d:06:da:53:f8:b8:27:b0:5f."); }