A. 如何用FTP下載網站源碼
使用FTP的軟體來下載 直接下載 網站的文件就可以看見源代碼了~~~~~~~~~~~
B. 求FTP CLIENT源碼(java)
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.StringTokenizer;
import sun.net.TelnetInputStream;
import sun.net.ftp.FtpClient;
public class FtpClientDemo {
public static int BUFFER_SIZE = 10240;
private FtpClient m_client;
// set the values for your server
private String host = "";
private String user = "";
private String password = "";
private String sDir = "";
private String m_sLocalFile = "";
private String m_sHostFile = "";
public FtpClientDemo() {
try {
System.out.println("Connecting to host " + host);
m_client = new FtpClient(host);
m_client.login(user, password);
System.out.println("User " + user + " login OK");
System.out.println(m_client.welcomeMsg);
m_client.cd(sDir);
System.out.println("Directory: " + sDir);
m_client.binary();
System.out.println("Success.");
} catch (Exception ex) {
System.out.println("Error: " + ex.toString());
}
}
protected void disconnect() {
if (m_client != null) {
try {
m_client.closeServer();
} catch (IOException ex) {
}
m_client = null;
}
}
public static int getFileSize(FtpClient client, String fileName)
throws IOException {
TelnetInputStream lst = client.list();
String str = "";
fileName = fileName.toLowerCase();
while (true) {
int c = lst.read();
char ch = (char) c;
if (c < 0 || ch == '\n') {
str = str.toLowerCase();
if (str.indexOf(fileName) >= 0) {
StringTokenizer tk = new StringTokenizer(str);
int index = 0;
while (tk.hasMoreTokens()) {
String token = tk.nextToken();
if (index == 4)
try {
return Integer.parseInt(token);
} catch (NumberFormatException ex) {
return -1;
}
index++;
}
}
str = "";
}
if (c <= 0)
break;
str += ch;
}
return -1;
}
protected void getFile() {
if (m_sLocalFile.length() == 0) {
m_sLocalFile = m_sHostFile;
}
byte[] buffer = new byte[BUFFER_SIZE];
try {
int size = getFileSize(m_client, m_sHostFile);
if (size > 0) {
System.out.println("File " + m_sHostFile + ": " + size
+ " bytes");
System.out.println(size);
} else
System.out.println("File " + m_sHostFile + ": size unknown");
FileOutputStream out = new FileOutputStream(m_sLocalFile);
InputStream in = m_client.get(m_sHostFile);
int counter = 0;
while (true) {
int bytes = in.read(buffer);
if (bytes < 0)
break;
out.write(buffer, 0, bytes);
counter += bytes;
}
out.close();
in.close();
} catch (Exception ex) {
System.out.println("Error: " + ex.toString());
}
}
protected void putFile() {
if (m_sLocalFile.length() == 0) {
System.out.println("Please enter file name");
}
byte[] buffer = new byte[BUFFER_SIZE];
try {
File f = new File(m_sLocalFile);
int size = (int) f.length();
System.out.println("File " + m_sLocalFile + ": " + size + " bytes");
System.out.println(size);
FileInputStream in = new FileInputStream(m_sLocalFile);
OutputStream out = m_client.put(m_sHostFile);
int counter = 0;
while (true) {
int bytes = in.read(buffer);
if (bytes < 0)
break;
out.write(buffer, 0, bytes);
counter += bytes;
System.out.println(counter);
}
out.close();
in.close();
} catch (Exception ex) {
System.out.println("Error: " + ex.toString());
}
}
public static void main(String argv[]) {
new FtpClientDemo();
}
}
C. linux下ftp客戶端源碼
sudo apt-get source $packagename
$packagename 換成ftp客戶端名字,如lftp,我猜lftp是最簡單的。
其他常見的有
kftpgrabber
KDE下ftp客戶端,支持編碼選擇。對中文支持較好
gftp
gnome下ftp客戶端,目前對中文支持尚不太好,受抱怨頗多。
fireftp
firefox的ftp客戶端插件,新版對中文支持較好。
FileZilla
對中文支持較好
CrossFTP
基於Java的穩定ftp客戶端和同步工具。優良的中文/Unicode支持。
D. 求每日定時在伺服器的FTP上取數據文件的源碼(JAVA)
這個是可以向伺服器端發送文字的程序,就是在客戶端發送一句hello在伺服器也可以接受到hello,這個程序可以修改一下就可以了。具體修改方法是增加一個定時器,然後把字元流改成位元組流,現在有點忙,你先研究啊,近兩天幫你寫寫看。
伺服器端:
import java.net.*;
import java.io.*;
public class DateServer {
public static void main(String[] args) {
ServerSocket server=null;
try{
server=new ServerSocket(6666);
System.out.println(
"Server start on port 6666...");
while(true){
Socket socket=server.accept();
new SocketHandler(socket).start();
/*
PrintWriter out=new PrintWriter(
new OutputStreamWriter(
socket.getOutputStream()
)
);
out.println(new java.util.Date().toLocaleString());
out.close();
*/
}
}catch(Exception e){
e.printStackTrace();
}finally{
if(server!=null) {
try{
server.close();
}catch(Exception ex){}
}
}
}
}
class SocketHandler extends Thread {
private Socket socket;
public SocketHandler(Socket socket) {
this.socket=socket;
}
public void run() {
try{
PrintWriter out=new PrintWriter(
new OutputStreamWriter(
socket.getOutputStream()
)
);
out.println(
new java.util.Date().
toLocaleString());
out.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
客戶端:
package com.briup;
import java.io.*;
import java.net.*;
public class FtpClient {
public static void main(String[] args) {
if(args.length==0) {
System.out.println("Usage:java FtpClient file_path");
System.exit(0);
}
File file=new File(args[0]);
if(!file.exists()||!file.canRead()) {
System.out.println(args[0]+" doesn't exist or can not read.");
System.exit(0);
}
Socket socket=null;
try{
socket=new Socket(args[1],Integer.parseInt(args[2]));
BufferedInputStream in=new BufferedInputStream(
new FileInputStream(file)
);
BufferedOutputStream out=new BufferedOutputStream(
socket.getOutputStream()
);
byte[] buffer=new byte[1024*8];
int i=-1;
while((i=in.read(buffer))!=-1) {
out.write(buffer,0,i);
}
System.out.println(socket.getInetAddress().getHostAddress()+" send file over.");
in.close();
out.close();
}catch(Exception e){
e.printStackTrace();
}finally{
if(socket!=null) {
try{
socket.close();
}catch(Exception ex){}
}
}
}
}
E. 如何把ftp上的源代碼下載下來
這個簡單,在網站根目錄上一級建個文件夾,把選擇網站根目錄後點復制,然後粘貼到新建的文件夾裡面,把文件在裡面壓縮一下,壓縮好後,點擊壓縮文件就會下載了。
下面wwwroot就是下載的壓縮好的源碼
F. 在源碼網下載的源碼怎麼上傳到空間里
網站上傳一般都用FTP軟體上傳到空間,ASP的源碼可用自動模式上傳,PHP的源碼像織夢,帝國都要用2進制模式上傳才行,目前最好用的FTP軟體是FlashFXP,下載地址:http://www.zzcms.cn/ruanjianhtml/40.html
G. 急求一個用易語言編寫的FTP客戶端軟體的源碼(如果滿意,給高)
精易模塊不是有這些FTP的操作嘛~~
H. 求一個完美無錯C#的FTP源碼,最好是中文
自己把這些方法寫到一個類里.我分二次回答,一次...您的回答內容多於10000字,請刪減! string ftpServerIP;
string ftpUserID;
string ftpPassword;
FtpWebRequest reqFTP;
private void Connect(String path)//連接ftp
{
// 根據uri創建FtpWebRequest對象
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(path));
// 指定數據傳輸類型
reqFTP.UseBinary = true;
// ftp用戶名和密碼
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
}
public FtpUpDown(string ftpServerIP, string ftpUserID, string ftpPassword)
{
this.ftpServerIP = ftpServerIP;
this.ftpUserID = ftpUserID;
this.ftpPassword = ftpPassword;
}
//都調用這個
//從ftp伺服器上獲得文件列表
private string[] GetFileList(string path, string WRMethods)
{
string[] downloadFiles;
StringBuilder result = new StringBuilder();
try
{
Connect(path);
reqFTP.Method = WRMethods;
WebResponse response = reqFTP.GetResponse();
StreamReader reader =
new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);//中文文件名
string line = reader.ReadLine();
while (line != null)
{
result.Append(line);
result.Append("\n");
line = reader.ReadLine();
}
// to remove the trailing '\n'
result.Remove(result.ToString().LastIndexOf('\n'), 1);
reader.Close();
response.Close();
return result.ToString().Split('\n');
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
downloadFiles = null;
return downloadFiles;
}
}
//從ftp伺服器上獲得文件列表
public string[] GetFileList(string path)
{
return GetFileList("ftp://" + ftpServerIP + "/" + path,
WebRequestMethods.Ftp.ListDirectory);
}
//從ftp伺服器上獲得文件列表
public string[] GetFileList()
{
return GetFileList("ftp://" + ftpServerIP + "/",
WebRequestMethods.Ftp.ListDirectory);
}
//從ftp伺服器上載文件的功能
public void Upload(string filename)
{
FileInfo fileInf = new FileInfo(filename);
string uri = "ftp://" + ftpServerIP + "/" + fileInf.Name;
Connect(uri);//連接
// 默認為true,連接不會被關閉
// 在一個命令之後被執行
reqFTP.KeepAlive = false;
// 指定執行什麼命令
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
// 上傳文件時通知伺服器文件的大小
reqFTP.ContentLength = fileInf.Length;
// 緩沖大小設置為kb
int buffLength = 2048;
byte[] buff = new byte[buffLength];
int contentLen;
// 打開一個文件流(System.IO.FileStream) 去讀上傳的文件
FileStream fs = fileInf.OpenRead();
try
{
// 把上傳的文件寫入流
Stream strm = reqFTP.GetRequestStream();
// 每次讀文件流的kb
contentLen = fs.Read(buff, 0, buffLength);
// 流內容沒有結束
while (contentLen != 0)
{
// 把內容從file stream 寫入upload stream
strm.Write(buff, 0, contentLen);
contentLen = fs.Read(buff, 0, buffLength);
}
// 關閉兩個流
strm.Close();
fs.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Upload Error");
}
}
I. 諸位大神誰有java 實現FTP客戶端的源碼
您好,/ **
*創建日期:2008年12月23日
*類名:Ftp.java
*類路徑:組織結構
*更改日誌:
* / 包組織結構;
進口的java.io.File;
進口java.io.FileInputStream中;
進口java.io.FileOutputStream中;
進口的java。 io.IOException;
進口sun.net.TelnetInputStream;
進口sun.net.TelnetOutputStream;
進口sun.net.ftp.FtpClient;
> / **
* @作者南山地獄
* @說明FTP操作
* /
公共類的Ftp {
/ **
* BR />獲取FTP目錄* / 公共無效getftpList(){
字元串伺服器=「IP地址 /輸入FTP伺服器/>弦樂用戶=」「;/ / FTP伺服器的登錄用戶名
字元串密碼=「」;/ /登錄FTP伺服器的用戶名
字元串路徑密碼=「」;/ / FTP路徑上的伺服器
嘗試{
> FtpClient的FTP客戶端=新FtpClient的();/ /創建FtpClient的對象
ftpClient.openServer(伺服器);/ /連接到FTP伺服器
ftpClient.login(用戶名,密碼);/ / FTP伺服器 BR />如果(path.length()= 0){
ftpClient.cd(路徑);
}
TelnetInputStream是= ftpClient.list();
詮釋三;
而{
System.out.print((char)的C)((C = is.read())= -1!);
}
掉} is.close ();
ftpClient.closeServer();/ /退出FTP伺服器
}趕上(IOException異常前){
System.out.println(ex.getMessage());
}
}
/ **
*
* /
公共無效getFtpFile(){
字元串伺服器=「」;/ / IP地址中輸入FTP伺服器
弦樂用戶=「」;/ / FTP伺服器的登錄用戶名
字元串密碼=「」;/ /登錄密碼為FTP伺服器的用戶名
字元串路徑=「路徑
字元串文件名「;/ /上=的FTP伺服器」「;/ /下載文件名稱
嘗試{
FtpClient的FTP客戶端=新FtpClient的();
ftpClient.openServer(伺服器);
ftpClient.login(用戶名,密碼);
如果(路徑。長度()= 0)
ftpClient.cd(路徑);!
ftpClient.binary();
TelnetInputStream是= ftpClient.get(文件名);
文件file_out =新的文件(文件名);
文件輸出流OS =新的文件輸出流(file_out);
位元組[]位元組=新位元組[1024];
詮釋三;
而((C = is.read(位元組))= -1){
os.write (位元組,0,C);
}!
掉} is.close();
os.close();
ftpClient.closeServer();
}趕上(IOException異常前){
System.out.println (ex.getMessage());
}
FTP}
/ **
*文件上傳到FTP
* /
公共無效putFtpFile() {
字元串伺服器=「」;/ /輸入IP地址對伺服器
字元串用戶的地址=「」;/ / FTP伺服器的登錄用戶名
字元串密碼=「」;/ / FTP伺服器登錄用戶名密碼
字元串路徑=「」就 / FTP伺服器/>字元串文件名=「」;/ /上傳的文件名
FtpClient的FTP客戶端=新的try { FtpClient的();
ftpClient.openServer(伺服器);
ftpClient.login(用戶名,密碼);
如果(!path.length()= 0)
ftpClient.cd (路徑);
ftpClient.binary();
TelnetOutputStream OS = ftpClient.put(文件名);
文件file_in =新的文件(文件名);
文件輸入流是=新的文件輸入流(file_in);
位元組[]位元組=新位元組[1024];
詮釋三;
同時(! (C = is.read(位元組))= -1){
操作系統。寫(位元組,0,C);
}
掉} is.close();
os.close();
ftpClient.closeServer();
}趕上(IOException異常前){
System.out.println(ex.getMessage());
}
}
}