user898465
user898465

Reputation: 944

Formatting a file name when using %1$s

Anyone help me with a formatting issue I have? I have a relative file path that my app uses to copy the file over and save it, such as:

\users\user1\test.pdf

Only problem is if you use %1$s as your formatter string it will copy this file over as a folder and then save the file in that folder, so you end up with the file name as part of the path, such as:

\users\user1\test.pdf\test.pdf

Anyone know the correct format string to get around this?

Upvotes: 2

Views: 459

Answers (1)

Mikel
Mikel

Reputation: 460

You should use File objects for handling paths.

File f = new File("test/something");

f.getParent();
f.getName();

etc...

Upvotes: 1

Related Questions