• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do I get Owner name of a file which is located in FTP server

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

How do i get Owner name of a file which is located in FTP.
please give me any guidance.

Advance Thanks
Hanuman
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you connecting to the FTP server? I know the Apache Commons Net library provides a method to get the owner name.
 
hanuman karyampudi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here the way of Connecting the FTP client


private static final DateFormat dateFormat = DateFormat
.getDateTimeInstance();

public static void main(String[] args) throws InstantiationException,
ClassNotFoundException, IllegalAccessException, FTPException,
ParseException, ConnectionException {
String ftpClientClassName = "com.myjavaworld.ftp.DefaultFTPClient";

String listParserClassName = "com.myjavaworld.ftp.DefaultListParser";

FTPClient client = (FTPClient) Class.forName(ftpClientClassName)
.newInstance();

ListParser parser = (ListParser) Class.forName(listParserClassName)
.newInstance();

client.setListParser(parser);

client.addFTPConnectionListener(new FTPConnectionListener() {
public void connectionOpened(FTPConnectionEvent evt) {
System.out.println(evt.getMessage());
}

public void connectionClosed(FTPConnectionEvent evt) {
System.out.println(evt.getMessage());
}
});
client.addControlConnectionListener(new ControlConnectionListener() {
public void commandSent(ControlConnectionEvent evt) {
System.out.println(evt.getMessage());
}

public void replyReceived(ControlConnectionEvent evt) {
System.out.println(evt.getMessage());
}
});
client.setPassive(true);

client.connect("hostname", 21);

client.login("username", "password");


RemoteFile workingDirectory = client.getWorkingDirectory();

list(client);

client.setWorkingDirectory(parser.createRemoteFile(workingDirectory,
".", true));

list(client);

client.disconnect();
}

private static void list(FTPClient client) throws FTPException,
ParseException, ConnectionException {
RemoteFile[] children = client.list();

for (int i = 0; i < children.length; ++i){
System.out.println("---------------------------owner-----------------"+children[i].getOwner()+"-----------------getfilename-----"+children[i].getName());
}
/*+ "\t"
+ ((children[i].isDirectory()) ? "<DIR>" : "<FILE>")
+ "\t"
+ children[i].getSize()
+ "\t"
+ dateFormat.format(new Date(children[i]
.getLastModified())) + "\t"
+ children[i].getName());*/
}
}


here the output of owner showing "Owner" in my case.
please give help on the same.

Thanks
Hanuman
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So your question is actually: why doesn't jMethods Secure FTP return the owner.
It looks like Secure FTP works like the Apache library. It takes the text output from an FTP server and parses it into a Java object. Unfortunately, if the format of the FTP server's replies don't match a known format, the parser will fail.
I would log into the FTP server by hand and see if it provides the owner when listing files. If it doesn't, then you aren't getting it without reconfiguring the server. If the FTP server does provide the owner, you can either try the Apache library and see if it works better or manually configure a parser for the jMethods library.
 
hanuman karyampudi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I am using Commons net API, I am not using Jmethods Secure FTP.
Please help me How to get owner of a file which is located in FTP server.

Advance Thanks
Hanuman
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

hanuman karyampudi wrote:Hi I am using Commons net API



The code above contains classes in the package com.myjavaworld.ftp. There are no such classes in the Apache Commons Net library, so either you posted the wrong code or you think you are using a different API than you actually are.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic