I have a file name as "FileToBeRetrieved.txt", which might be located under any folder under one root folder. I know only the root folder while my run-time, and I can't surely say the needed file is in under specific path. Please see the attached image for better understanding. In that I've marked the required file with blue color.
So From the specific root folder, is there any possibility to search and retrieve that specific file.. ?
Jesper de Jong wrote:Class java.io.File contains methods for listing the files and subdirectories that are present in a directory. To find a file that is somewhere down in a subdirectory, you'd have to call these methods recursively on the subdirectories, until you find the file that you're looking for. Have a look at the API documentation of class java.io.File.
Thanks Jesper.. Actually I've started this approach already, but may I know, is this the only way to achieve this..? Can't we have any api say directly search the file in single method ... and FYI I'm working this scenario in eclipse (root directory is my workspace, that can we retrieve through eclipse core api)
do you know any api for done this in eclipse, please let me know...
Campbell Ritchie wrote:Eclipse is not a runtime, but a development environment. It uses the standard Java™ API, and any other API you need to download and add to your classpath. When you have finished developing, it should work by [double-]clicking the resultant .jar. Use the same API you would use without Eclipse.
Ritchie., I'm in mid of developing plug-in which fits into eclipse. The actual requirement is, have to get a file as IDocument with just file name not full path of the file. As I mentioned in attachment, we can get the current user workspace through code, under that workspace there could be many projects(or folders), and files. Within that user current workspace I need to retrieve the file with its name. Since we can't surely say the file lying under specific folder, we cant give the full path ... isn't it.? As of now I've implement logic said by jesper and able to get the file,. But my question is, don't we have any other option to do this ..?
[For more explanation of requirement, how the "open resources" functionality working in eclipse. In that "open resources" if we type any name of the file without bothering about where its lying (must be in current workspace), the eclipse have intelligence to open that file right... same thing is I want to achieve in my plug-in]