private void initFTPFile() { try { String path = getURL().getPath(); // 如果且以"/"结尾,去掉"/" if (path.endsWith("/")) { path = path.substring(0, path.lastIndexOf('/')); } // 资源在服务器中所属目录 String checkPath = path.substring(0, path.lastIndexOf('/')); // 如果所属目录为根目录 if (checkPath.length() == 0) { checkPath = "/"; } String fileName = path.substring(path.lastIndexOf('/')); fileName = fileName.substring(fileName.lastIndexOf('/') + 1); ftpClient.enterLocalPassiveMode(); // 从上级目录的子目录中过滤出当前资源 FTPFile[] files = ftpClient.listFiles(recode(checkPath), new FtpFileFilterByName(fileName)); if (files != null && files.length == 1) { ftpFile = files[0]; } else { throw new TinySysRuntimeException("查找资源失败,url=" + getURL()); } } catch (Exception e) { throw new VFSRuntimeException(e); } }