String parsing... need to get a substring

I am making a file explorer.  Now for my file copy method it takes two inputs, a file source and file destination.  All are File objects.
Here is an example of what I need:

String source:  C:\Windows\Test\test.txt
String dest:    C:\Somewhere\Windows\Test\test.txt

The user would have dragged the folder C:\Windows\Test\ to C:\Somewhere\
The file will be an exact copy... but I need to extract that Windows\Test\ and append it to the destination String.

Right now, a user would do the above and the resultant File would be C:\Somewhere\test.txt... I need that extra directory information.  
Help?
m3th0dm4nAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

glottisCommented:
if the format always remain the same, you could get rid of the first 3 characters this way:

assuming you have to ditch the first 3 characters like 'c:\' or 'd:\'
String source = c:\windows\test\test.txt.
String newSource = source.substring(3); // this will start to copy all the string starting from the 4th character till the end.

also there is another way:
String source = c:\windows\test\test.txt.
int index = source.indexOf("\"); // return the first position of the '\' in source.
String newSource = source.substring(++index);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
m3th0dm4nAuthor Commented:
Yes that did it.  I finally ended up doing this:

File destFile = new File(dest.getParent() + "\\" + src.toString().substring(3));

Thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.