[英]Java FTP over TLS/SSL (FTPS- Implicit) Server in Java - Several Error
I am trying to connecting a server with FTPSClient (true implicit), port 990, and it seems the connection is ok, but it says that the file PDF inside cannot be found. 我正在尝试将服务器与FTPSClient(真隐式)的端口990连接,似乎连接正常,但是它说找不到内部的PDF文件。
String protocol = "TLS"; // TLS / SSL
boolean isImpicit = true;
int timeoutInMillis = 3000;
FTPSClient client = new FTPSClient(protocol, isImpicit);
client.setDataTimeout(timeoutInMillis);
client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
try
{
int reply;
client.connect(server, port);
client.login(user, pass);
client.setFileType(FTP.BINARY_FILE_TYPE);
client.execPBSZ(0);
client.execPROT("P");
System.out.println("Connected to " + server + ".");
reply = client.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply))
{
client.disconnect();
System.err.println("FTP server refused connection.");
System.exit(1);
}
client.listFiles();
boolean retrieved = client.retrieveFile(Constantes.DIRECCION_FTP_PDF_FACTURAS + nombre_factura, new FileOutputStream(Constantes.DIRECCION_FTP_LOCAL_DESCARGAS + nombre_factura));
}
catch (Exception e)
{
if (client.isConnected())
{
try
{
client.disconnect();
}
catch (IOException ex)
{
ex.printStackTrace();
}
}
System.err.println("Could not connect to server.");
e.printStackTrace();
return;
}
finally
{
System.out.println("# client disconnected");
client.disconnect();
}
}
The error I got is java.io.FileNotFoundException I tried writing the full path since C:\\ , and without it, but nothing works. 我遇到的错误是java.io.FileNotFoundException我尝试从C:\\开始编写完整路径,没有它,但是没有任何效果。
Anybody can help me? 有人可以帮助我吗?
Thanks. 谢谢。
EDIT: IT WORKS NOW! 编辑:现在工作!
The path "Program Files" contains a space and maybe FileInputStream does not manage to resolve it properly. 路径“ Program Files”包含一个空格,并且FileInputStream可能无法正确解析它。 May give it a try to put your folder to "C:/Temp/" and test it again.
可以尝试将您的文件夹放入“ C:/ Temp /”并再次进行测试。
Where does this FileNotFoundException happen exactly? FileNotFoundException到底在哪里发生?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.