ftp-client

Android app doesn't work on Android 4

寵の児 提交于 2019-11-28 12:26:25
问题 I created an Android project on 2.3.3 and tried it on mobile 2.3.3, everything works OK. It didn't work on mobile 4, so I re-built for Android 4, but I have the same problem. This is the code: public void FTP_Download(){ String server = "192.168.1.135"; int port = 21; String user = "pc1"; String pass = "1551"; FTPClient ftpClient = new FTPClient(); try { ftpClient.connect(server, port); ftpClient.login(user, pass); ftpClient.enterLocalPassiveMode(); ftpClient.setFileType(FTP.BINARY_FILE_TYPE)

FTPClient corrupts the images while uploading to ftp server on android?

我的未来我决定 提交于 2019-11-28 12:17:57
I'm trying to upload images to a FTP server (on my local PC) from Android Phone (HTC Desire HD). Images are going to FTP server but they are corrupted. And the method (ftpClient.storeFile()) throws IOException (Bad File Number) Please help me. This is the corrupted image link: http://imageshack.us/photo/my-images/820/komikb.jpg/ And this is the code: FTPClient ftpClient = new FTPClient(); try { ftpClient.connect("192.168.2.14"); ftpClient.setFileType(FTP.BINARY_FILE_TYPE); ftpClient.setFileTransferMode(FTP.BINARY_FILE_TYPE); ftpClient.setSoTimeout(10000); ftpClient.enterLocalPassiveMode(); if

FTP client server model for file transfer in Java

烈酒焚心 提交于 2019-11-28 11:48:10
Well, I am trying to implement the ftp server and ftp client in Java. I am trying to receive a file from server. Following is line of codes. I am able to achieve Connection between server and client, but unable to send filename to server also. Well can anyone guide me whether this approach is correct or if not, please suggest proper changes. Server's Implementation: import java.net.*; import java.io.*; class MyServer { ServerSocket ss; Socket clientsocket; BufferedReader fromclient; InputStreamReader isr; PrintWriter toclient; public MyServer() { String str = new String("hello"); try { //

Monitoring progress using Apache Commons FTPClient

本秂侑毒 提交于 2019-11-28 07:47:23
I have a simple FTPClient class that downloads files form an FTP server. I also need to monitor progress of the download, but I do not see a way how. The actually download files function is a simple function of (your ftp client name).retrieveFile(arg1,arg2); How can I monitor the download progress? Thanks, Anon. You need a CountingOutputStream (as seen on Commons IO: http://commons.apache.org/io/api-release/index.html ). You create one of those, wrap your destination OutputStream in it, and then you can check the ByteCount on demand to monitor the download progress.. EDIT: You'd do something

FTPClient - Java, upload file

做~自己de王妃 提交于 2019-11-28 06:50:26
I'm trying to do a VERY simple file upload. I want a Java FTPClient that can upload any file I tell it to. But the pdf always gets all messed up and my pdf editor (Adobe) won't open it, saying there is an I/O error. I'm using the following class: import org.apache.commons.net.ftp.FTPClient; .... FTPClient client = new FTPClient(); FileInputStream fis = null; try { client.connect("mydomain.com"); client.login("user", "password"); String filename = "myPDF.pdf"; fis = new FileInputStream(filename); client.storeFile("temp.pdf", fis); fis.close(); client.logout(); } catch (IOException e) { e

FTPClient.listFiles not working

戏子无情 提交于 2019-11-28 04:24:06
问题 I am trying to list all the files under a specific directory in a ftp server. FTPFile[] subFiles = ftpClient.listFiles("directory"); Although the directory is a valid one , but the code gets stuck while calling listFiles , what may be the reason. ? Further i would like to mention that a seperate netbeans project accessing the same FTP server is working fine with the same code , but a maven project is having the problem. please help. 回答1: Try to use passive mode. I assume that you are using

Download the latest file from an FTP server

女生的网名这么多〃 提交于 2019-11-28 00:32:49
I have to download the latest file from an FTP Server. I know how download the latest file from my computer, but I don't how download from an FTP server. How can I download the latest file from a FTP Server? This is my program to download the latest file from my Computer public Form1() { InitializeComponent(); string startFolder = @"C:\Users\user3\Desktop\Documentos XML"; System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(startFolder); IEnumerable<System.IO.FileInfo> fileList = dir.GetFiles("*.*", System.IO.SearchOption.AllDirectories); IEnumerable<System.IO.FileInfo> fileQuerry = from

FtpClient storeFile always return False

萝らか妹 提交于 2019-11-27 21:20:14
Please figure this out. The code runs properly without any exception. FTPClient ftp = new FTPClient(); ftp.connect(server); if(!ftp.login(username, password)) { ftp.logout(); return false; } int reply = ftp.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { ftp.disconnect(); return false; } InputStream in = new FileInputStream(localfile); ftp.setFileType(ftp.BINARY_FILE_TYPE, ftp.BINARY_FILE_TYPE); ftp.setFileTransferMode(ftp.BINARY_FILE_TYPE); Store = ftp.storeFile(destinationfile, in); in.close(); ftp.logout(); ftp.disconnect(); } catch (Exception ex) { ex.printStackTrace(); return

How to copy a file on the FTP server to a directory on the same server in Java?

谁都会走 提交于 2019-11-27 20:13:58
I'm using Apache Commons FTP to upload a file. Before uploading I want to check if the file already exists on the server and make a backup from it to a backup directory on the same server. Does anyone know how to copy a file from a FTP server to a backup directory on the same server? public static void uploadWithCommonsFTP(File fileToBeUpload){ FTPClient f = new FTPClient(); FTPFile backupDirectory; try { f.connect(server.getServer()); f.login(server.getUsername(), server.getPassword()); FTPFile[] directories = f.listDirectories(); FTPFile[] files = f.listFiles(); for(FTPFile file:directories)

parsing a date string from FTPClient.getModificationTime()

非 Y 不嫁゛ 提交于 2019-11-27 19:33:29
问题 I am trying to parse a date string which is a modification date of a file on FTP server. Following is the code. String dateString = mFTPClient.getModificationTime(PDF_FILE_NAME_PS); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); Date modificationDate = dateFormat.parse(dateString.substring(dateString.indexOf(" "))); Log.v(TAG, "inside downloadservice dateString="+dateString); Log.v(TAG, "inside downloadservice modificationdate="+modificationDate.toString()); I get this