Java: Specifying file path so that code works on cygwin(running on Windows) and Linux.

BufferedReader br = new BufferedReader(new FileReader(_filesrc));
_filesrc is a command line argument which i have specified as /c/abc/filename
I get this error:
java.io.FileNotFoundException: \c\abc\filename
(The system cannot find the path specified)
If i hardcode the line as follows, it works:
                    File file1 = new File("C:/abc/filename");
                  BufferedReader br = new BufferedReader(new FileReader(_filesrc));

I am coding on Eclipse on Windows, and running the command to call the code on cygwin. I would like this code to work on cygwin and on Linux.
renisenbbAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

mccarlIT Business Systems Analyst / Software DeveloperCommented:
_filesrc is a command line argument which i have specified as /c/abc/filename
I get this error:
java.io.FileNotFoundException: \c\abc\filename

Can't you just leave the code as is (with the command line argument as above) and then specify the correct path on the command line, ie. C:\abc\filename

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
CEHJCommented:
I get this error:
java.io.FileNotFoundException: \c\abc\filename

Open in new window

In that case, something must be converting it. What is that something?
krakatoaCommented:
Excuse me for interrupting, but why the leading frontslash ?
CEHJCommented:
That's Cygwin for C:\ afaicr ;)

Another idea: use a URI. Not only are they cross platform, but they will also enable you to read from things other than the file system, should the need arise.
krakatoaCommented:
>That's Cygwin for< . . .  Ah.  ;
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.