Power Man
Power Man

Reputation: 166

Android: how can i find file path

i'm using a source code like this:

PrintWriter fout = new PrintWriter(new FileWriter("plot.txt"));
fout.println("#\tX\tY");

i want to find path of "plot.txt", any help? best regards.

Upvotes: 0

Views: 754

Answers (1)

Manu Zi
Manu Zi

Reputation: 2370

If you use File instead of FileWriter you can easily call the getPath() or getAbsolutePath() method from File.

I have looked in the api of PrintWriter and FileWriter and there are no methods to determine the path.

http://developer.android.com/reference/java/io/PrintWriter.html

http://developer.android.com/reference/java/io/FileWriter.html

Example:

File f = new File("test/.././file.txt");
System.out.println(f.getPath());
System.out.println(f.getAbsolutePath());

Upvotes: 1

Related Questions