|
||||||
| Java Help Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
I'm making a FTPClient using the Apache library org.apache.commons.net.ftp
I made this function, which doesn't work correct because it goes to the "deepest" folder in the server and I don't know how to get back to try the other folders. Code:
public static String isFile(String file, String director) throws IOException{
ftp.changeWorkingDirectory(director);
FTPFile f[] = ftp.listFiles();
sortByDirectory(f);
for(int i = 0; i < f.length; i++){
if(f[i].isDirectory()){
return isFile(file, f[i].getName());
}
else
if(f[i].getName().equals(file))
return director;
}
return "";
}
|
| Sponsored Links |
|
|
|
|||
|
Quote:
is this a normal function or something else.. Maybe I thing i gotta learn many things from you bro. |
|
|||
|
isFile() is going to return the directory where the file is found, but this is just a prototype/ideea.
If the file isn't found anywhere, I return an empty string. (return ""; ) In my main function, I'm saving the result in a String variable, and check for the blank string. I'm a beginner also...I just got hired at a small programming company and have a deadline ![]() |
|
|||
|
Quote:
Thats just a part of a project I'm working on, the find function. |
| Sponsored Links |
|
|
|
|||
|
Dude I have asked it to my friends about this problem of yours.. and well his vague idea is that why dont you simply open the file by using the html command <input type='file'> if you are using servlets ... and he says isFile() is usually used to distinguish between directory and file...it rearly helps in browsing the files on server..
|
|
|||
|
I think there's a confusion... I'm not using the function isFile from the Apache library, I just defined my own function as isFile ...
I don't understand how that HTML code can help me find a file, my problem is to browse within folders/subfolders when you don't have any idea how the structure looks like. Thanks anyway, turns out I don't need that function after all because our application will have a DB Server which will contain all the FTP links for all the files. I just need to make a function which would verify is the link is valid. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Project: ionFiles - Joomla Simple File Download | Jordan | Community Projects | 331 | 11-26-2008 12:35 PM |
| Windows Shortcut List - Saves Time | 2stamlers | The Lounge | 6 | 04-10-2008 07:58 AM |
| DNS Hacking | John | Tutorials | 1 | 04-09-2008 01:34 PM |
| server client application - (i really need your help) | sarahnetworking | C and C++ | 5 | 03-04-2008 11:47 AM |
| Getting PHP to execute a file on the server? | phpforfun | PHP Forum | 9 | 02-19-2008 11:45 AM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |