如何java判断ftp服务器上路径是否存在
答案:1 悬赏:0 手机版
解决时间 2021-02-16 06:36
- 提问者网友:鐵馬踏冰河
- 2021-02-15 05:50
如何java判断ftp服务器上路径是否存在
最佳答案
- 五星知识达人网友:第幾種人
- 2021-02-15 06:56
要注意的是程序有可能和FTP不再同一台服务器上,所以要多做一些工作,先要根据获取FTP的IP,根据这个IP的FTP目录 在进行判断
代码如下
=======接口部分===============
IMPORT JAVA.RMI.REMOTE;
IMPORT JAVA.RMI.REMOTEEXCEPTION;
PUBLIC INTERFACE IDOREMOTE EXTENDS REMOTE {
PUBLIC INT GETSERVERTIME() THROWS REMOTEEXCEPTION;
}
=======接口实现===============
PUBLIC CLASS DOREMOTEIMPL EXTENDS UNICASTREMOTEOBJECT IMPLEMENTS IDOREMOTE {
PROTECTED DOREMOTEIMPL() THROWS REMOTEEXCEPTION {
SUPER();
}
PRIVATE STATIC FINAL LONG SERIALVERSIONUID = -8158779541912069375L;
PUBLIC INT GETSERVERTIME() THROWS REMOTEEXCEPTION {
RETURN INTEGER.PARSEINT(NEW SIMPLEDATEFORMAT("YYYYMMDD").FORMAT(NEW DATE()));
// RETURN NEW DATE();
}
========SERVER端绑定===============
PUBLIC STATIC VOID MAIN(STRING[] ARGS) {
TRY {
LOCATEREGISTRY.CREATEREGISTRY(8808);
DOREMOTEIMPL SERVER = NEW DOREMOTEIMPL();
NAMING.REBIND("//LOCALHOST:8808/DATE-SERVER", SERVER);
} CATCH (JAVA.NET.MALFORMEDURLEXCEPTION ME) {
SYSTEM.OUT.PRINTLN("MALFORMED URL: " + ME.TOSTRING());
} CATCH (REMOTEEXCEPTION RE) {
SYSTEM.OUT.PRINTLN("REMOTE EXCEPTION: " + RE.TOSTRING());
}
}
===========客户端的调用方式============
STRING URL = "//LOCALHOST:8808/DATE-SERVER";
IDOREMOTE RMIOBJECT = (IDOREMOTE) NAMING.LOOKUP(URL);
SYSTEM.OUT.PRINTLN(" SERVER DATE: " + RMIOBJECT.GETSERVERTIME());
代码如下
=======接口部分===============
IMPORT JAVA.RMI.REMOTE;
IMPORT JAVA.RMI.REMOTEEXCEPTION;
PUBLIC INTERFACE IDOREMOTE EXTENDS REMOTE {
PUBLIC INT GETSERVERTIME() THROWS REMOTEEXCEPTION;
}
=======接口实现===============
PUBLIC CLASS DOREMOTEIMPL EXTENDS UNICASTREMOTEOBJECT IMPLEMENTS IDOREMOTE {
PROTECTED DOREMOTEIMPL() THROWS REMOTEEXCEPTION {
SUPER();
}
PRIVATE STATIC FINAL LONG SERIALVERSIONUID = -8158779541912069375L;
PUBLIC INT GETSERVERTIME() THROWS REMOTEEXCEPTION {
RETURN INTEGER.PARSEINT(NEW SIMPLEDATEFORMAT("YYYYMMDD").FORMAT(NEW DATE()));
// RETURN NEW DATE();
}
========SERVER端绑定===============
PUBLIC STATIC VOID MAIN(STRING[] ARGS) {
TRY {
LOCATEREGISTRY.CREATEREGISTRY(8808);
DOREMOTEIMPL SERVER = NEW DOREMOTEIMPL();
NAMING.REBIND("//LOCALHOST:8808/DATE-SERVER", SERVER);
} CATCH (JAVA.NET.MALFORMEDURLEXCEPTION ME) {
SYSTEM.OUT.PRINTLN("MALFORMED URL: " + ME.TOSTRING());
} CATCH (REMOTEEXCEPTION RE) {
SYSTEM.OUT.PRINTLN("REMOTE EXCEPTION: " + RE.TOSTRING());
}
}
===========客户端的调用方式============
STRING URL = "//LOCALHOST:8808/DATE-SERVER";
IDOREMOTE RMIOBJECT = (IDOREMOTE) NAMING.LOOKUP(URL);
SYSTEM.OUT.PRINTLN(" SERVER DATE: " + RMIOBJECT.GETSERVERTIME());
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯