Saif
Saif

Reputation: 7042

How to get path of file using System Specific separator from Eclipse

Option Copy Qualified Name in Eclipse

give me the complete file name in this way

/ProjecName/src/packageName/fileName

Now when Use this path any where in my windows it require \ instead of / as separator

How can I get the file name

\ProjecName\src\packageName\fileName

This way

Because every time I have to replace this manually again with a text editor. Is there a setting or direct way to gain what I want.

Upvotes: 1

Views: 59

Answers (2)

SpaceTrucker
SpaceTrucker

Reputation: 13556

this is not quite as comfortable as the copy qualified name option, but:

  • open the Properties View
  • select the file (or other element) you want to copy the path for
  • copy the value of the location property value in the Properties View

Unfortunately the context menu option Copy for the Properties View will also copy the property name so that the result is the concatenation of name and value.

Upvotes: 3

Shiladittya Chakraborty
Shiladittya Chakraborty

Reputation: 4418

Use this :

String workingDirectory = System.getProperty("user.dir");      
String absoluteFilePath = "";
absoluteFilePath = workingDirectory + File.separator + filename;

System.out.println("Final filepath : " + absoluteFilePath);

Upvotes: 0

Related Questions