开发者

Formatting a file name when using %1$s

开发者 https://www.devze.com 2023-03-30 09:56 出处:网络
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:

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开发者_JAVA技巧, 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?


You should use File objects for handling paths.

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

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

etc...
0

精彩评论

暂无评论...
验证码 换一张
取 消