Yes, the username I am using for authenticating with the FTP server has the read/write permissions for the file.
I can open konsole and connect to the server. I have the konsole configured to read UTF-8 encoding. So when execute "mget <filename>" I can get the file downloaded. I am very curious whether I can debug the apache commons library internals as to what is really sent to the server ( which command ) and what is retrieved from the server. If there is issue with the commons library while converting strings ( not using UTF-8 encoding ) or sending the strings to the server in wrong format, then I should be able to debug this. Thanks Susanta On Thu, Jun 14, 2012 at 4:39 PM, Indudhar Devanath <[email protected]>wrote: > check the permissions on that file on the UNIX server. Make sure you have > read write permissions to that file. > > Indu > > On 14 June 2012 12:45, Susanta Mohapatra <[email protected] > >wrote: > > > Thanks Indu for replying. > > > > I tried the following as per the API in the link: > > > > ftp = new FTPClient(); > > FTPClientConfig conf = new > FTPClientConfig(FTPClientConfig.SYST_UNIX); > > conf.setServerLanguageCode("de"); > > ftp.configure(conf); > > > > before the line: > > ftp.connect(host); > > > > It still returns "Stream1 status: 550 Failed to open file." error. > > > > Has anyone ever tried to get files with non-english characters? I am > > starting to think something is wrong with the api code. > > > > Thanks > > Susanta > > > > On Thu, Jun 14, 2012 at 12:18 PM, Indudhar Devanath <[email protected] > > >wrote: > > > > > try using FTPClientConfig to specify the language. Refer the API here > - > > > > > > > > > http://commons.apache.org/net/api-3.1/org/apache/commons/net/ftp/FTPClientConfig.html > > > > > > Indu > > > > > > On 13 June 2012 16:00, Susanta Mohapatra <[email protected] > > > >wrote: > > > > > > > Hello everyone, > > > > > > > > I am not able to fetch filenames with german characters using > > FTPClient. > > > > > > > > Here is the sample code: > > > > > > > > private static void testFTP(String host, String pathname, String > > > resource) > > > > { > > > > boolean error = false; > > > > FTPClient ftp = null; > > > > try { > > > > int reply; > > > > ftp = new FTPClient(); > > > > ftp.connect(host); > > > > ftp.setControlEncoding("UTF-8"); > > > > ftp.setAutodetectUTF8(true); > > > > > > > > ftp.login("xxxxx", "xxxxx"); > > > > System.out.println("Connected to " + host + "."); > > > > System.out.print(ftp.getReplyString()); > > > > > > > > // After connection attempt, you should check the reply code to > > > verify > > > > // success. > > > > reply = ftp.getReplyCode(); > > > > > > > > if(!FTPReply.isPositiveCompletion(reply)) { > > > > ftp.disconnect(); > > > > System.err.println("FTP server refused connection."); > > > > System.exit(1); > > > > } > > > > boolean ok = ftp.changeWorkingDirectory(pathname); > > > > System.out.println("Change dir ok: " + ok) ; > > > > > > > > FTPFile[] files = ftp.listFiles(); > > > > if(files != null) { > > > > for(FTPFile f : files) { > > > > System.out.println("file: " + f.getName()); > > > > if(f.getName().equals(resource)) { > > > > System.out.println("Resouce found: " + resource); > > > > } > > > > > > > > } > > > > } > > > > > > > > InputStream is = ftp.retrieveFileStream(resource); > > > > reply = ftp.getReplyCode(); > > > > System.out.print("Stream1 status: " + ftp.getReplyString()); > > > > System.out.println("Stream: " + is); > > > > > > > > InputStream is1 = ftp.retrieveFileStream("rssfeed1.xml"); > > > > System.out.print("Stream2 status: " + ftp.getReplyString()); > > > > System.out.println("Stream: " + is1); > > > > if(is != null) > > > > is.close(); > > > > if(is1 != null) > > > > is1.close(); > > > > // transfer files > > > > ftp.logout(); > > > > } catch(IOException e) { > > > > error = true; > > > > e.printStackTrace(); > > > > } finally { > > > > if(ftp.isConnected()) { > > > > try { > > > > ftp.disconnect(); > > > > } catch(IOException ioe) { > > > > // do nothing > > > > } > > > > } > > > > System.exit(error ? 1 : 0); > > > > } > > > > } > > > > > > > > > > > > I am invoking this method as: > > > > > > > > testFTP("xxxxxx", "dir", "sozial-fähigen-Anwendungen.txt"); > > > > > > > > The program runs with positive match for resource name in the list > > > command. > > > > But fails to return stream for the above file name, wheras the other > > file > > > > returns stream. > > > > > > > > This is the output: > > > > > > > > Connected to xxxxxx > > > > 230 Login successful. > > > > Change dir ok: true > > > > file: rssfeed1.xml > > > > file: sozial-fähigen-Anwendungen.txt > > > > Resource found: "sozial-fähigen-Anwendungen.txt" > > > > Stream1 status: 550 Failed to open file. > > > > Stream: null > > > > Stream2 status: 150 Opening BINARY mode data connection for > > rssfeed1.xml > > > > (8035 bytes). > > > > Stream: org.apache.commons.net.io.SocketInputStream@1632847 > > > > > > > > Any help for this matter is highly appreciated. > > > > > > > > Thanks > > > > Susanta > > > > > > > > > >
