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());
}
}
}