Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Java Help

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.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-09-2008, 04:52 AM
tomitzel tomitzel is offline
Learning Programmer
 
Join Date: Jul 2008
Location: Romania
Age: 21
Posts: 34
Rep Power: 2
tomitzel is on a distinguished road
Send a message via MSN to tomitzel Send a message via Yahoo to tomitzel Send a message via Skype™ to tomitzel
Question Find file on a server with FTP

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 "";	
	}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 07-09-2008, 04:53 PM
Acti Acti is offline
Newbie
 
Join Date: Jul 2008
Location: Maharashtra,India
Age: 20
Posts: 22
Rep Power: 2
Acti is on a distinguished road
Send a message via Yahoo to Acti
Default Re: Find file on a server with FTP

Quote:
Originally Posted by tomitzel View Post
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 "";	
	}
How are u invoking the isFile() ... I dont understand..

is this a normal function or something else..

Maybe I thing i gotta learn many things from you bro.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-09-2008, 06:19 PM
tomitzel tomitzel is offline
Learning Programmer
 
Join Date: Jul 2008
Location: Romania
Age: 21
Posts: 34
Rep Power: 2
tomitzel is on a distinguished road
Send a message via MSN to tomitzel Send a message via Yahoo to tomitzel Send a message via Skype™ to tomitzel
Default Re: Find file on a server with FTP

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-10-2008, 12:16 PM
Craid Craid is offline
Newbie
 
Join Date: Jul 2008
Posts: 4
Rep Power: 0
Craid is on a distinguished road
Default Re: Find file on a server with FTP

You could try to open the site in Internet Explorer and use CTRL-F.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-10-2008, 01:58 PM
tomitzel tomitzel is offline
Learning Programmer
 
Join Date: Jul 2008
Location: Romania
Age: 21
Posts: 34
Rep Power: 2
tomitzel is on a distinguished road
Send a message via MSN to tomitzel Send a message via Yahoo to tomitzel Send a message via Skype™ to tomitzel
Default Re: Find file on a server with FTP

Quote:
Originally Posted by Craid View Post
You could try to open the site in Internet Explorer and use CTRL-F.
LoL, your funny!
Thats just a part of a project I'm working on, the find function.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 07-15-2008, 06:09 AM
Acti Acti is offline
Newbie
 
Join Date: Jul 2008
Location: Maharashtra,India
Age: 20
Posts: 22
Rep Power: 2
Acti is on a distinguished road
Send a message via Yahoo to Acti
Default Re: Find file on a server with FTP

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..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 07-15-2008, 06:14 AM
tomitzel tomitzel is offline
Learning Programmer
 
Join Date: Jul 2008
Location: Romania
Age: 21
Posts: 34
Rep Power: 2
tomitzel is on a distinguished road
Send a message via MSN to tomitzel Send a message via Yahoo to tomitzel Send a message via Skype™ to tomitzel
Default Re: Find file on a server with FTP

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

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


All times are GMT -5. The time now is 03:02 AM.

Contest Stats

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

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads