本文整理汇总了Java中org.apache.commons.net.ftp.FTPClient.cwd方法的典型用法代码示例。如果您正苦于以下问题:Java FTPClient.cwd方法的具体用法?Java FTPClient.cwd怎么用?Java FTPClient.cwd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.net.ftp.FTPClient
的用法示例。
在下文中一共展示了FTPClient.cwd方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFileList
import org.apache.commons.net.ftp.FTPClient; //导入方法依赖的package包/类
public List<MetaFile2> getFileList() throws IOException, AuthenticationException {
FTPClient ftp = Session.getInstance().getFTPClient(mUri);
ftp.cwd(mUri.getPath());
org.apache.commons.net.ftp.FTPFile[] listFiles = ftp.listFiles();
if(listFiles==null)
return null;
ArrayList<MetaFile2> list = new ArrayList<MetaFile2>();
for(org.apache.commons.net.ftp.FTPFile f : listFiles){
if(!f.getName().equals("..")|| !f.getName().equals(".")){
FTPFile2 sf = new FTPFile2(f , Uri.withAppendedPath(mUri, f.getName()));
list.add(sf);
}
}
return list;
}
示例2: testPathNames
import org.apache.commons.net.ftp.FTPClient; //导入方法依赖的package包/类
/**
* Test of obscure path names in the FTP server
*
* RFC959 states that paths are constructed thus...
* <string> ::= <char> | <char><string>
* <pathname> ::= <string>
* <char> ::= any of the 128 ASCII characters except <CR> and <LF>
*
* So we need to check how high characters and problematic are encoded
*/
public void testPathNames() throws Exception
{
logger.debug("Start testPathNames");
FTPClient ftp = connectClient();
String PATH1="testPathNames";
try
{
int reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply))
{
fail("FTP server refused connection.");
}
boolean login = ftp.login(USER_ADMIN, PASSWORD_ADMIN);
assertTrue("admin login successful", login);
reply = ftp.cwd("/Alfresco/User*Homes");
assertTrue(FTPReply.isPositiveCompletion(reply));
// Delete the root directory in case it was left over from a previous test run
try
{
ftp.removeDirectory(PATH1);
}
catch (IOException e)
{
// ignore this error
}
// make root directory for this test
boolean success = ftp.makeDirectory(PATH1);
assertTrue("unable to make directory:" + PATH1, success);
success = ftp.changeWorkingDirectory(PATH1);
assertTrue("unable to change to working directory:" + PATH1, success);
assertTrue("with a space", ftp.makeDirectory("test space"));
assertTrue("with exclamation", ftp.makeDirectory("space!"));
assertTrue("with dollar", ftp.makeDirectory("space$"));
assertTrue("with brackets", ftp.makeDirectory("space()"));
assertTrue("with hash curley brackets", ftp.makeDirectory("space{}"));
//Pound sign U+00A3
//Yen Sign U+00A5
//Capital Omega U+03A9
assertTrue("with pound sign", ftp.makeDirectory("pound \u00A3.world"));
assertTrue("with yen sign", ftp.makeDirectory("yen \u00A5.world"));
// Test steps that do not work
// assertTrue("with omega", ftp.makeDirectory("omega \u03A9.world"));
// assertTrue("with obscure ASCII chars", ftp.makeDirectory("?/.,<>"));
}
finally
{
// clean up tree if left over from previous run
ftp.disconnect();
}
}
示例3: testRenameCase
import org.apache.commons.net.ftp.FTPClient; //导入方法依赖的package包/类
/**
* Test of rename case ALF-20584
*
*/
public void testRenameCase() throws Exception
{
logger.debug("Start testRenameCase");
FTPClient ftp = connectClient();
String PATH1="testRenameCase";
try
{
int reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply))
{
fail("FTP server refused connection.");
}
boolean login = ftp.login(USER_ADMIN, PASSWORD_ADMIN);
assertTrue("admin login successful", login);
reply = ftp.cwd("/Alfresco/User*Homes");
assertTrue(FTPReply.isPositiveCompletion(reply));
// Delete the root directory in case it was left over from a previous test run
try
{
ftp.removeDirectory(PATH1);
}
catch (IOException e)
{
// ignore this error
}
// make root directory for this test
boolean success = ftp.makeDirectory(PATH1);
assertTrue("unable to make directory:" + PATH1, success);
ftp.cwd(PATH1);
String FILE1_CONTENT_2="That's how it is says Pooh!";
ftp.storeFile("FileA.txt" , new ByteArrayInputStream(FILE1_CONTENT_2.getBytes("UTF-8")));
assertTrue("unable to rename", ftp.rename("FileA.txt", "FILEA.TXT"));
}
finally
{
// clean up tree if left over from previous run
ftp.disconnect();
}
}