Change file name and its extension before output it Java -



Change file name and its extension before output it Java -

lets i've got file in d: has filepath as:

d:\work\2012\018\08\2b558ad8-4ea4-4cb9-b645-6c9a9919ba01

at moment name of file not meaningful. doesn't have format. have ability create file object above filepath in java , alter name , format before writing bytes. new path following:

d:\work\2012\018\08\mywork.pdf

after changes have been made, should still able gain access original file per normal.

i know type of file , name there won't problem getting details.

just rename file:

file file = new file(oldfilepath); boolean success = file.renameto(new file(newfilepath));

you give filename , utilize same parent current file:

file file = new file(oldfilepath); file.renameto(new file(file.getparentfile(), newfilename));

java file filepath

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -