java读取文件问题??? 我现在有两台Linux的服务器,A、BA部署这我的工程,我现在要读取B上指定路径的文件,怎么办,局域网中的两台服务器,B提供用户名、密码、开放7777端口我要读temp目录下的*.dat文件,救急!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 b转成http上的路径? ab服务器是物理上不同么?用ftp协议? 通过ftp可以么? /** * 从远程ftp目录下载文件到本地 <功能详细描述> * * @param ftpInfo ftp站点信息 * @param remoteFileName 远程文件名 * @param localFilePath 本地文件路径 * * @return void [返回类型说明] * @throws FTPException * @throws IOException * @throws PortalException * @exception throws [违例类型] [违例说明] * @see [类、类#方法、类#成员] */ public static void download(FtpSite ftpInfo, String remoteFileName, String localFilePath) throws ServerException, IOException, FTPException { if (log.isDebugEnable()) { log.debug("download start"); } FTPClient ftp = null; FileOutputStream fos = null; try { // 构造ftp客户端信息 ftp = FtpProxy.getFtpClient(ftpInfo); if (null == ftp) { throw new ServerException(ResultCode.FTP_CONSTRUCT_FAILD, "ftp实例创建失败!"); } // 文件名 String fileName = getFileName(remoteFileName); // 本地文件全路径,包括文件名 String localFileName = localFilePath + fileName; byte[] buf = null; buf = ftp.get(remoteFileName); // 构造本地文件 File file = new File(localFileName); File parents = file.getParentFile(); // 文件的父目录不存在,创建该目录 if (!parents.exists()) { parents.mkdirs(); } // 本地文件不存在,则创建本地文件 if (!file.exists()) { file.createNewFile(); } fos = new FileOutputStream(file); fos.write(buf); fos.flush(); } finally { if (null != ftp) { ftp.quit(); } if (null != fos) { fos.close(); } } }下载文件到本地 使用java.net url 只能读文件,不能读文件夹用ftp下载,不能标记哪些文件读过,哪些没读过 动态代理的内部实现。例子:数据库连接。 求解一个纠结的题 怎么查看一个函数的返回值类型 有关正则匹配的问题 大家好! 我想请教一下 java swing 能出widget (鱼鱼秀)的东东吗?有会的 请赐教! 数据流图中的“加工”在visio中用那个形状来画? 有没有办法让jtoolbar响应鼠标双击事件? 继承与接口(面向对象理论知识),请进: java的学习方法?在线等候!谢谢!! 谁能找到MOCHA的JAVA反编译软件 一个关于 Keytool的题目,哪位朋友给指点一下?感谢! java long
ab服务器是物理上不同么?用ftp协议?
/**
* 从远程ftp目录下载文件到本地 <功能详细描述>
*
* @param ftpInfo ftp站点信息
* @param remoteFileName 远程文件名
* @param localFilePath 本地文件路径
*
* @return void [返回类型说明]
* @throws FTPException
* @throws IOException
* @throws PortalException
* @exception throws [违例类型] [违例说明]
* @see [类、类#方法、类#成员]
*/
public static void download(FtpSite ftpInfo, String remoteFileName, String localFilePath)
throws ServerException, IOException, FTPException
{
if (log.isDebugEnable())
{
log.debug("download start");
}
FTPClient ftp = null;
FileOutputStream fos = null;
try
{
// 构造ftp客户端信息
ftp = FtpProxy.getFtpClient(ftpInfo);
if (null == ftp)
{
throw new ServerException(ResultCode.FTP_CONSTRUCT_FAILD, "ftp实例创建失败!");
}
// 文件名
String fileName = getFileName(remoteFileName);
// 本地文件全路径,包括文件名
String localFileName = localFilePath + fileName;
byte[] buf = null;
buf = ftp.get(remoteFileName);
// 构造本地文件
File file = new File(localFileName);
File parents = file.getParentFile();
// 文件的父目录不存在,创建该目录
if (!parents.exists())
{
parents.mkdirs();
}
// 本地文件不存在,则创建本地文件
if (!file.exists())
{
file.createNewFile();
}
fos = new FileOutputStream(file);
fos.write(buf);
fos.flush();
}
finally
{
if (null != ftp)
{
ftp.quit();
}
if (null != fos)
{
fos.close();
}
}
}下载文件到本地
用ftp下载,不能标记哪些文件读过,哪些没读过