javaftp掃描文件
㈠ java連接ftp在線讀取文件,不下載文件直接讀 怎麼讀 求代碼
就我所了解到的ftp的協議裡面應該沒有直接讀文件內容的命令,因此那些直接在線讀取文件內容的要求應該是先下載到本地,然後讀取本地文件的內容。當然,你也可以仿照FTP的協議發送對應的指示到伺服器,直接把伺服器返回的信息放到緩存里(以前做過,忘記了),這樣可以避免生成文件,不過這個就要詳細了解ftp協議和socket編程才行。
㈡ 在Java中利用ftp來訪問文件主要過程
ftpClient = new FtpClient();
ftpClient.openServer(ip, port);
ftpClient.login(user, password);
先連接 登錄,後可以調用方法 下載文件 刪除文件 等等
㈢ java怎麼打開FTP伺服器上的文件
http的話就用
httpclient
。open後,可以返回一個
InputStream
。這個就是你要讀到
文件流
。
原理的話,參考你用瀏覽器打開這個鏈接顯示的內容。
這個返回的是一個HTML網頁,需要你解析出裡面的文字(一般來說取body中間的內容就行)
其實對於這種文件一般用FTP來下載的。樓上寫的那個不對,哈哈。
需要的話自己最好去查一下,怎麼用,我有代碼,不過告訴你的話也不太好?
URL
url
=
new
URL("http://你的地址");
URLConnection
connection
=
url.openConnection();
InputStream
is
=
connection.getInputStream();
BufferedReader
br
=
new
BufferedReader(new
InputStreamReader(is,"gb2312"));
下面就是解析這個字元串來,自己來吧
㈣ 使用Java實現FTP伺服器
FTP是Internet 上用來傳送文件的協議 在Internet上通過FTP 伺服器可以進行文件的上傳(Upload)或下載(Download) FTP是實時聯機服務 在使用它之前必須是具有該服務的一個用戶(用戶名和口令) 工作時客戶端必須先登錄到作為伺服器一方的計算機上 用戶登錄後可以進行文件搜索和文件傳送等有關操作 如改變當前工作目錄 列文件目錄 設置傳輸參數及傳送文件等 使用FTP可以傳送所有類型的文件 如文本文件 二進制可執行文件 圖象文件 聲音文件和數據壓縮文件等 FTP 命令 FTP 的主要操作都是基於各種命令基礎之上的 常用的命令有 ◆ 設置傳輸模式 它包括ASCⅡ(文本) 和BINARY 二進制模式 ◆ 目錄操作 改變或顯示遠程計算機的當前目錄(cd dir/ls 命令) ◆ 連接操作 open命令用於建立同遠程計算機的連接 close命令用於關閉連接 ◆ 發送操作 put命令用於傳送文件到遠程計算機 mput 命令用於傳送多個文件到遠程計算機 ◆ 獲取操作 get命令用於接收一個文件 mget命令用於接收多個文件 編程思路 根據FTP的工作原理 在主函數中建立一個伺服器套接字埠 等待客戶端請求 一旦客戶端請求被接受 伺服器程序就建立一個伺服器分線程 處理客戶端的命令 如果客戶端需要和伺服器端進行文件的傳輸 則建立一個新的套接字連接來完成文件的操作編程技巧說明 主函數設計 在主函數中 完成伺服器埠的偵聽和服務線程的創建 我們利用一個靜態字元串變數initDir 來保存伺服器線程運行時所在的工作目錄 伺服器的初始工作目錄是由程序運行時用戶輸入的 預設為C盤的根目錄 具體的代碼如下 public class ftpServer extends Thread{ private Socket socketClient; private int counter; private static String initDir; public static void main(String[] args){ if(args length != ) { initDir = args[ ]; }else{ initDir = c: ;} int i = ; try{ System out println( ftp server started! ) //監聽 號埠 ServerSocket s = new ServerSocket( ) for( ){ //接受客戶端請求 Socket ining = s accept() //創建服務線程 new ftpServer(ining i) start() i++; } }catch(Exception e){} } 線程類的設計 線程類的主要設計都是在run()方法中實現 用run()方法得到客戶端的套接字信息 根據套接字得到輸入流和輸出流 向客戶端發送歡迎信息 FTP命令的處理 ( ) 訪問控制命令 ◆ user name(user) 和 password (pass) 命令處理代碼如下 if(str startsWith( USER )){ user = str substring( ) user = user trim() out println( Password ) } if(str startsWith( PASS )) out println( User +user+ logged in ) User 命令和 Password 命令分別用來提交客戶端用戶輸入的用戶名和口令 ◆ CWD (CHANGE WORKING DIRECTORY) 命令處理代碼如下 if(str startsWith( CWD )){ String str = str substring( ) dir = dir+ / +str trim() out println( CWD mand succesful ) } 該命令改變工作目錄到用戶指定的目錄 ◆ CDUP (CHANGE TO PARENT DIRECTORY) 命令處理代碼如下 if(str startsWith( CDUP )){ int n = dir lastIndexOf( / ) dir = dir substring( n) out println( CWD mand succesful ) } 該命令改變當前目錄為上一層目錄 ◆ QUIT命令處理代碼如下 if(str startsWith( QUIT )) { out println( GOOD BYE ) done = true;} 該命令退出及關閉與伺服器的連接 輸出GOOD BYE
( ) 傳輸參數命令 ◆ Port命令處理代碼如下 if(str startsWith( PORT )) { out println( PORT mand successful ) int i = str length() ; int j = str lastIndexOf( ) int k = str lastIndexOf( j ) String str str ;str = ; str = ;for(int l=k+ ; lstr = str + str charAt(l) } for(int l=j+ ;l<=i;l++){ str = str + str charAt(l) } tempPort = Integer parseInt(str ) * * +Integer parseInt(str ) } 使用該命令時 客戶端必須發送客戶端用於接收數據的 位IP 地址和 位 的TCP 埠號 這些信息以 位為一組 使用十進制傳輸 中間用逗號隔開 ◆ TYPE命令處理代碼如下 if(str startsWith( TYPE )){ out println( type set ) } TYPE 命令用來完成類型設置 ( ) FTP 服務命令 ◆ RETR (RETEIEVE) 和 STORE (STORE)命令處理的代碼 if(str startsWith( RETR )){ out println( Binary data connection ) str = str substring( ) str = str trim() RandomAccessFile outFile = newRandomAccessFile(dir+ / +str r ) Socket tempSocket = new Socket(host tempPort) OutputStream outSocket= tempSocket getOutputStream() byte byteBuffer[]= new byte[ ]; int amount; try{ while((amount = outFile read(byteBuffer)) != ){
outSocket write(byteBuffer amount) } outSocket close() out println( transfer plete ) outFile close() tempSocket close() } catch(IOException e){} } if(str startsWith( STOR )){ out println( Binary data connection ) str = str substring( ) str = str trim() RandomAccessFile inFile = newRandomAccessFile(dir+ / +str rw ) Socket tempSocket = new Socket(host tempPort) InputStream inSocket= tempSocket getInputStream() byte byteBuffer[] = new byte[ ]; int amount; try{ while((amount =inSocket read(byteBuffer) )!= ){ inFile write(byteBuffer amount) } inSocket close() out println( transfer plete ) inFile close() tempSocket close() } catch(IOException e) {} } 文件傳輸命令包括從伺服器中獲得文件RETR和向伺服器中發送文件STOR 這兩個命令的處理非常類似 處理RETR命令時 首先得到用戶要獲得的文件的名稱 根據名稱創建一個文件輸入流 然後和客戶端建立臨時套接字連接 並得到一個輸出流 隨後 將文件輸入流中的數據讀出並藉助於套接字輸出流發送到客戶端 傳輸完畢以後 關閉流和臨時套接字 STOR 命令的處理也是同樣的過程 只是方向正好相反 ◆ DELE (DELETE)命令處理代碼如下 if(str startsWith( DELE )){ str = str substring( ) str = str trim() File file = new File(dir str) boolean del = file delete() out println( delete mand successful ) } DELE 命令用於刪除伺服器上的指定文件 ◆ LIST命令處理代碼如下 if(str startsWith( LIST )) { try{ out println( ASCII data ) Socket tempSocket = new Socket(host tempPort) PrintWriter out = new PrintWriter(tempSocket getOutputStream() true) File file = new File(dir) String[] dirStructure = new String[ ]; dirStructure= file list() String strType= ; for(int i= ;iif( dirStructure[i] indexOf( ) == ) { strType = d ;} else{ strType = ;} out println(strType+dirStructure[i]) } tempSocket close() out println( transfer plete ) } catch(IOException e) {} LIST 命令用於向客戶端返回伺服器中工作目錄下的目錄結構 包括文件和目錄的列表 處理這個命令時 先創建一個臨時的套接字向客戶端發送目錄信息 這個套接字的目的埠號預設為 然後為當前工作目錄創建File 對象 利用該對象的list()方法得到一個包含該目錄下所有文件和子目錄名稱的字元串數組 然後根據名稱中是否含有文件名中特有的 來區別目錄和文件 最後 將得到的名稱數組通過臨時套接字發送到客戶端 lishixin/Article/program/Java/hx/201311/26847
㈤ 如何 用Java 實現 獲取FTP伺服器上的所有文件名,已知FTP的密碼,用戶名!遠程獲取!
public void ftpJdomFile(String dir) throws FileNotFoundException, IOException{
//創立根節點
// 下面這個方法是列出指定目錄下的所有文件和文件夾
List dirslist=Arrays.asList(new File(dir).listFiles());
for (Iterator i = dirslist.iterator(); i.hasNext();) {
// System.out.println(i.next()); // line 1
String s=i.next().toString();
if (new File(s).isFile()) {
System.out.println(s+"-文件");
}
if (new File(s).isDirectory()) {
System.out.println(s+"++++++++文件夾");
ftpJdomFile(s);
}
}
}
㈥ 用java寫一段程序掃描文件夾下所有後綴為.txt的文件代碼
《用java寫一段程序掃描文件夾下所有後綴》網路網盤txt 最新全集下載
鏈接: https://pan..com/s/1nKtaJpp1I3E0tTe3BGVS9Q
Java是一門面向對象編程語言,不僅吸收了C++語言的各種優點,還摒棄了C++里難以理解的多繼承、指針等概念,因此Java語言具有功能強大和簡單易用兩個特徵。
㈦ 如何用Java實現FTP伺服器
FTP(File Transfer Protocol 文件傳輸協議)是Internet 上用來傳送文件的協議。在Internet上通過FTP 伺服器可以進行文件的上傳(Upload)或下載(Download)。FTP是實時聯機服務,在使用它之前必須是具有該服務的一個用戶(用戶名和口令),工作時客戶端必須先登錄到作為伺服器一方的計算機上,用戶登錄後可以進行文件搜索和文件傳送等有關操作,如改變當前工作目錄、列文件目錄、設置傳輸參數及傳送文件等。使用FTP可以傳送所有類型的文件,如文本文件、二進制可執行文件、圖象文件、聲音文件和數據壓縮文件等。
FTP 命令
FTP 的主要操作都是基於各種命令基礎之上的。常用的命令有:
設置傳輸模式,它包括ASCⅡ(文本) 和BINARY 二進制模式;
目錄操作,改變或顯示遠程計算機的當前目錄(cd、dir/ls 命令);
連接操作,open命令用於建立同遠程計算機的連接;close命令用於關閉連接;
發送操作,put命令用於傳送文件到遠程計算機;mput 命令用於傳送多個文件到遠程計算機;
獲取操作,get命令用於接收一個文件;mget命令用於接收多個文件。
?
import java.net.Socket;import org.apache.log4j.Logger;/** * 角色——伺服器A * @author Leon * */public class ServerA{ public static void main(String[] args){ final String F_DIR = "c:/test";//根路徑 final int PORT = 22;//監聽埠號 Logger.getRootLogger(); Logger logger = Logger.getLogger("com"); try{ ServerSocket s = new ServerSocket(PORT); logger.info("Connecting to server A..."); logger.info("Connected Successful! Local Port:"+s.getLocalPort()+". Default Directory:'"+F_DIR+"'."); while( true ){ //接受客戶端請求 Socket client = s.accept(); //創建服務線程 new ClientThread(client, F_DIR).start(); } } catch(Exception e) { logger.error(e.getMessage()); for(StackTraceElement ste : e.getStackTrace()){ logger.error(ste.toString()); } } }}import java.io.BufferedReader; import java.io.File;import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.io.OutputStream;import java.io.PrintWriter;import java.io.RandomAccessFile;import java.net.ConnectException;import java.net.InetAddress;import java.net.ServerSocket;import java.net.Socket;import java.net.UnknownHostException;import java.nio.charset.Charset;import java.util.Random;import org.apache.log4j.Logger;/** * 客戶端子線程類 * @author Leon * */public class ClientThread extends Thread { private Socket socketClient;//客戶端socket private Logger logger;//日誌對象 private String dir;//絕對路徑 private String pdir = "/";//相對路徑 private final static Random generator = new Random();//隨機數 public ClientThread(Socket client, String F_DIR){ this.socketClient = client; this.dir = F_DIR; } @Override public void run() { Logger.getRootLogger(); logger = Logger.getLogger("com"); InputStream is = null; OutputStream os = null; try { is = socketClient.getInputStream(); os = socketClient.getOutputStream(); } catch (IOException e) { logger.error(e.getMessage()); for(StackTraceElement ste : e.getStackTrace()){ logger.error(ste.toString()); } } BufferedReader br = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))); PrintWriter pw = new PrintWriter(os); String clientIp = socketClient.getInetAddress().toString().substring(1);//記錄客戶端IP String username = "not logged in";//用戶名 String password = "";//口令 String command = "";//命令 boolean loginStuts = false;//登錄狀態 final String LOGIN_WARNING = "530 Please log in with USER and PASS first."; String str = "";//命令內容字元串 int port_high = 0; int port_low = 0; String retr_ip = "";//接收文件的IP地址 Socket tempsocket = null; //列印歡迎信息 pw.println("220-FTP Server A version 1.0 written by Leon Guo"); pw.flush(); logger.info("("+username+") ("+clientIp+")> Connected, sending welcome message..."); logger.info("("+username+") ("+clientIp+")> 220-FTP Server A version 1.0 written by Leon Guo"); boolean b = true; while ( b ){ try { //獲取用戶輸入的命令 command = br.readLine(); if(null == command) break; } catch (IOException e) { pw.println("331 Failed to get command"); pw.flush(); logger.info("("+username+") ("+clientIp+")> 331 Failed to get command"); logger.error(e.getMessage()); for(StackTraceElement ste : e.getStackTrace()){ logger.error(ste.toString()); } b = false; } /* * 訪問控制命令 */ // USER命令 if(command.toUpperCase().startsWith("USER")){ logger.info("(not logged in) ("+clientIp+")> "+command); username = command.substring(4).trim(); if("".equals(username)){ pw.println("501 Syntax error"); pw.flush(); logger.info("(not logged in) ("+clientIp+")> 501 Syntax error"); username = "not logged in"; } else{ pw.println("331 Password required for " + username); pw.flush(); logger.info("(not logged in) ("+clientIp+")> 331 Password required for " + username); } loginStuts = false; } //end USER // PASS命令 else if(command.toUpperCase().startsWith("PASS")){ logger.info("(not logged in) ("+clientIp+")> "+command); password = command.substring(4).trim(); if(username.equals("root") && password.equals("root")){ pw.println("230 Logged on"); pw.flush(); logger.info("("+username+") ("+clientIp+")> 230 Logged on");// logger.info("客戶端 "+clientIp+" 通過 "+username+"用戶登錄"); loginStuts = true; } else{ pw.println("530 Login or password incorrect!"); pw.flush(); logger.info("(not logged in) ("+clientIp+")> 530 Login or password incorrect!"); username = "not logged in"; } } //end PASS // PWD命令 else if(command.toUpperCase().startsWith("PWD")){ logger.info("("+username+") ("+clientIp+")> "+command); if(loginStuts){// logger.info("用戶"+clientIp+":"+username+"執行PWD命令"); pw.println("257 /""+pdir+"/" is current directory"); pw.flush(); logger.info("("+username+") ("+clientIp+")> 257 /""+pdir+"/" is current directory"); } else{ pw.println(LOGIN_WARNING); pw.flush(); logger.info("("+username+") ("+clientIp+")> "+LOGIN_WARNING); } } //end PWD // CWD命令 else if(command.toUpperCase().startsWith("CWD")){ logger.info("("+username+") ("+clientIp+")> "+command); if(loginStuts){ str = command.substring(3).trim(); if("".equals(str)){ pw.println("250 Broken client detected, missing argument to CWD. /""+pdir+"/" is current directory."); pw.flush(); logger.info("("+username+") ("+clientIp+")> 250 Broken client detected, missing argument to CWD. /""+pdir+"/" is current directory."); } else{ //判斷目錄是否存在 String tmpDir = dir + "/" + str; File file = new File(tmpDir); if(file.exists()){//目錄存在 dir = dir + "/" + str; if("/".equals(pdir)){ pdir = pdir + str; } else{ pdir = pdir + "/" + str; }// logger.info("用戶"+clientIp+":"+username+"執行CWD命令"); pw.println("250 CWD successful. /""+pdir+"/" is current directory"); pw.flush(); logger.info("("+username+") ("+clientIp+")> 250 CWD successful. /""+pdir+"/" is current directory"); } else{//目錄不存在 pw.println("550 CWD failed. /""+pdir+"/": directory not found."); pw.flush(); logger.info("("+username+") ("+clientIp+")> 550 CWD failed. /""+pdir+"/": directory not found.");
㈧ java編輯一個掃描文件的方法,要求可以掃描根目錄下的所有文件
package com.sunjob;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
public class Js {
/**
* @param args
*/
//初始化n,用於計數
static int n=0;
public static void get(File file) {
try {
//判斷文件是否是文件,如果是文件,獲取路徑,並計數
if(file.isFile())
{
n++;
System.out.println(file.getAbsolutePath());
}
else
{
//如果是文件夾,聲明一個數組放文件夾和他的子文件
File[] f=file.listFiles();
//遍歷文件件下的文件,並獲取路徑
for (File file2 : f) {
get(file2);
}
}
} catch (RuntimeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
這是掃描c盤的所有文件,可以修改
File file=new File("c:\\");
get(file);
System.out.println("文件個數為:"+n);
}
}
㈨ java ftp 和 sftp的區別
FTP是文件傳輸協議。在網站上,如果你想把文件和人共享,最便捷的方式莫過於把文件上傳到FTP伺服器上,其他人通過FTP客戶端程序來下載所需要的文件。 FTP進行文件傳輸需要通過埠進行。一般所需埠為: 1. 控制鏈路—TCP埠21。控制器端。用於發送指令給伺服器以及等待伺服器響應。 2. 數據鏈路---TCP埠20。數據傳輸埠。用來建立數據傳輸通道的。主要用來從客戶向伺服器發送一個文件、從伺服器向客戶發送一個文件、從伺服器向客戶發送文件或目錄列表。 FTP為了適應不同的網路環境,支持主動連接和被動連接兩種模式。這兩種模式都主要針對數據鏈路進行的,跟控制鏈路無關。 FTP的安全隱患: 一、FTP伺服器軟體漏洞。 二、明文口令。 三、FTP旗標。 四、通過FTP伺服器進行埠掃描。 五、數據劫持。 FTP的安全策略: 一、使用較比安全的系統和FTP服務軟體。 二、使用密文傳輸用戶名和口令。 三、更改服務軟體的旗標。 四、加強協議安全性。 SFTP是Secure File Transfer Protocol的縮寫,是安全文件傳送協議。可以為傳輸文件提供一種安全的加密方法。跟ftp幾乎語法功能一樣。 SFTP是SSH的一部分,是一種傳輸檔案至Blogger伺服器的安全方式。它...
㈩ 用java怎麼獲取ftp上的文件
public class FtpClientUtil {
FtpClient ftpClient;
private String server;
private int port;
private String userName;
private String userPassword;
public FtpClientUtil(String server,int port,String userName,String userPassword)
{
this.server=server;
this.port=port;
this.userName=userName;
this.userPassword=userPassword;
}
/**
* 鏈接到伺服器
* @return
*/
public boolean open()
{
if(ftpClient!=null&&ftpClient.serverIsOpen())
return true;
try
{
ftpClient= new FtpClient();
ftpClient.openServer(server,port);
ftpClient.login(userName, userPassword);
ftpClient.binary();
return true;
}
catch(Exception e)
{
e.printStackTrace();
ftpClient=null;
return false;
}
}
public boolean cd(String dir){
boolean f = false;
try {
ftpClient.cd(dir);
} catch (IOException e) {
Logs.error(e.toString());
return f;
}
return true;
}
/**
* 上傳文件到FTP伺服器
* @param localPathAndFileName 本地文件目錄和文件名
* @param ftpFileName 上傳後的文件名
* @param ftpDirectory FTP目錄如:/path1/pathb2/,如果目錄不存在回自動創建目錄
* @throws Exception
*/
public boolean upload(String localDirectoryAndFileName,String ftpFileName,String ftpDirectory)throws Exception {
if(!open())
return false;
FileInputStream is=null;
TelnetOutputStream os=null;
try
{
char ch = ' ';
if (ftpDirectory.length() > 0)
ch = ftpDirectory.charAt(ftpDirectory.length() - 1);
for (; ch == '/' || ch == '\\'; ch = ftpDirectory.charAt(ftpDirectory.length() - 1))
ftpDirectory = ftpDirectory.substring(0, ftpDirectory.length() - 1);
int slashIndex = ftpDirectory.indexOf(47);
int backslashIndex = ftpDirectory.indexOf(92);
int index = slashIndex;
String dirall = ftpDirectory;
if (backslashIndex != -1 && (index == -1 || index > backslashIndex))
index = backslashIndex;
String directory = "";
while (index != -1) {
if (index > 0) {
String dir = dirall.substring(0, index);
directory = directory + "/" + dir;
ftpClient.sendServer("XMKD " + directory + "\r\n");
ftpClient.readServerResponse();
}
dirall = dirall.substring(index + 1);
slashIndex = dirall.indexOf(47);
backslashIndex = dirall.indexOf(92);
index = slashIndex;
if (backslashIndex != -1 && (index == -1 || index > backslashIndex))
index = backslashIndex;
}
ftpClient.sendServer("XMKD " + ftpDirectory + "\r\n");
ftpClient.readServerResponse();
os = ftpClient.put(ftpDirectory + "/"
+ ftpFileName);
File file_in = new File(localDirectoryAndFileName);
is = new FileInputStream(file_in);
byte bytes[] = new byte[1024];
int i;
while ((i = is.read(bytes)) != -1)
os.write(bytes, 0, i);
//清理垃圾
return true;
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
finally
{
if (is != null)
is.close();
if (os != null)
os.close();
}
}
/**
* 從FTP伺服器上下載文件並返回下載文件長度
* @param ftpDirectoryAndFileName
* @param localDirectoryAndFileName
* @return
* @throws Exception
*/
public long download(String ftpDirectoryAndFileName,String localDirectoryAndFileName)throws Exception
{
long result = 0;
if(!open())
return result;
TelnetInputStream is = null;
FileOutputStream os = null;
try
{
is = ftpClient.get(ftpDirectoryAndFileName);
java.io.File outfile = new java.io.File(localDirectoryAndFileName);
os = new FileOutputStream(outfile);
byte[] bytes = new byte[1024];
int c;
while ((c = is.read(bytes)) != -1)
{
os.write(bytes, 0, c);
result = result + c;
}
}
catch (Exception e)
{
throw e;
}
finally
{
if (is != null)
is.close();
if (os != null)
os.close();
}
return result;
}
/**
* 返回FTP目錄下的文件列表
* @param ftpDirectory
* @return
*/
public List<String> getFileNameList(String ftpDirectory)
{
List<String> list = new ArrayList<String>();
if(!open())
return list;
try
{
DataInputStream dis = new DataInputStream(ftpClient.nameList(ftpDirectory));
String filename = "";
while((filename=dis.readLine())!=null)
{
list.add(filename);
}
} catch (Exception e)
{
e.printStackTrace();
}
return list;
}
/**
* 刪除FTP上的文件
* @param ftpDirAndFileName
*/
public boolean deleteFile(String ftpDirAndFileName)
{
if(!open())
return false;
ftpClient.sendServer("DELE "+ftpDirAndFileName+"\r\n");
return true;
}
/**
* 刪除FTP目錄
* @param ftpDirectory
*/
public boolean deleteDirectory(String ftpDirectory)
{
if(!open())
return false;
ftpClient.sendServer("XRMD "+ftpDirectory+"\r\n");
return true;
}
/**
* 關閉鏈接
*/
public void close()
{
try
{
if(ftpClient!=null&&ftpClient.serverIsOpen())
ftpClient.closeServer();
}catch(Exception e)
{
}
}
}望採納,謝謝。