private FTPFile existsFile(AFTPClient client, String strPath, boolean isFile) throws PageException, IOException { strPath = strPath.trim(); if (strPath.equals("/")) { FTPFile file = new FTPFile(); file.setName("/"); file.setType(FTPFile.DIRECTORY_TYPE); return file; } // get parent path FTPPath path = new FTPPath(client, strPath); String p = path.getPath(); String n = path.getName(); strPath = p; if ("//".equals(p)) strPath = "/"; if (isFile) strPath += n; // when directory FTPFile[] files = null; try { files = client.listFiles(p); } catch (IOException e) { } if (files != null) { for (int i = 0; i < files.length; i++) { if (files[i].getName().equalsIgnoreCase(n)) { return files[i]; } } } return null; }
private boolean existsDir(AFTPClient client, String strPath) throws PageException, IOException { strPath = strPath.trim(); // get parent path FTPPath path = new FTPPath(client, strPath); String p = path.getPath(); String n = path.getName(); strPath = p + "" + n; if ("//".equals(p)) strPath = "/" + n; if (!strPath.endsWith("/")) strPath += "/"; return client.directoryExists(directory); }