File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Changing FilePath from full filepath to project folder filepath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Changing FilePath from full filepath to project folder filepath" Watch "Changing FilePath from full filepath to project folder filepath" New topic
Author

Changing FilePath from full filepath to project folder filepath

Frank Sween
Greenhorn

Joined: Feb 19, 2009
Posts: 8
this might be simple/ might not be simple

the assignment is to make an mp3 player with a folder full of mp3's that the player will be able to access and play mp3s from it. I have it working fine in that it gets the filepath of the mp3's and isable to play them just fine...


The problem I am envisioning is that the filepath that I have hardcoded into my code will only work from my computer, when I hand the project up TOMORROW , it will not work on my lecturers computer when he is marking it.



This filepath is my memory stick (Where I have eclipse installed) , its in 'MyTunes v2.1' project folder, 'myTune_v2_1' package,,, this is where the classes are and the 'mp3s' folder is in same place.


When I hand it up TOMORROW , the filepath will be wrong but I am handing up the whole project folder so I am hoping there is a way I can just put \\mp3s\\" +filePath); ,,, but I have tried this and it doesnt work.


Any help is greatly appreciated and a quick reply is even more so , as I have already said I have to hand this up in 12 hours time.
Lee Kian Giap
Ranch Hand

Joined: Jan 23, 2008
Posts: 210
Hi there, here the help I can offer



If you would like to really detect another USB drive, this solution might not suitable for you.


However, I encourage you to study the jdk api documentation, which is a place to get solution.
Moreover, 1 hour is enough for you to do a google search for a solution, be responsible for your project, cheers !


SCJP 6, SCWCD 5, SCBCD 5
Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
Here is the code that is used to find the path if the directory name is given.

But it will search all your entire drives for the folder which may take your entire life term.

I am sure this is not the efficient code.

But gives you some idea about java.io package.

Try modify this code as per your needs



SCJP 6,SCWCD 5,SCBCD 5

Failure is not an option.
Frank Sween
Greenhorn

Joined: Feb 19, 2009
Posts: 8
you guys are great

im in a little over my head though i was hoping for a quick easy fix but now i see its not so simple to do in 5 hours ( i need sleep and ive been working different parts of this project since i last posted about 7 hours ago)

thanks anyway i will look into your solutions tomorow



Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
Frank Sween wrote:this might be simple/ might not be simple . . .
We like to reserve this forum for simple things, and I think this falls in the category of "might not be simple", so I shall move this thread.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Changing FilePath from full filepath to project folder filepath
 
Similar Threads
dvd player
Plug and Play problems
Very much dissapointed with Linux
Audio/Video streaming?
How to add buffer to play mp3 in the Samsung U600?