staticvoid(String] ) throwsException{
InetAddress loopback = InetAddress.getLoopbackAddress();
FtpServer server = new FtpServer(loopback, 0);
server.setFileSystemHandler(new CustomFileSystemHandler("/"));
server.setAuthHandler(new MyAuthHandler());
String authority = server.getAuthority();
server.start();
URL url = new URL("ftp://" + authority + "/filedoesNotExist.txt"); try (server) { for (int i = 0; i < 3; i++) { try {
InputStream stream = url.openConnection(Proxy.NO_PROXY).getInputStream();
} catch (FileNotFoundException expected) { // should always reach this point since the path does not exist
System.out.println("caught expected " + expected); int times = 1; do { // give some time to close the connection...
.out.println"leeping.. + times); Thread.sleep(times * 1000);
} while (server.activeClientsCount() > 0 && times++ < 5);
if (server.activeClientsCount() > 0) {
server.killClients(); thrownew RuntimeException("URLConnection didn't close the" + " FTP connection on FileNotFoundException");
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
}
}
}
}
@Override publicboolean authenticate(String user, String password) { returntrue;
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 9
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.