I would like to save an exisiting excel with a new name. but the contents should be same. It should perform the save as property for any any excel. please help
Asked
Active
Viewed 427 times
-4
-
possible duplicate of [How to rename a file using java.io packages?](http://stackoverflow.com/questions/6080295/how-to-rename-a-file-using-java-io-packages) – Srinath Ganesh Sep 09 '13 at 05:51
1 Answers
1
contents rename and save as
Quoting duplicate post
File oldfile = new File(old_name);
File newfile = new File(new_name);
boolean rename = oldfile.renameTo(newfile);
API:
Returns true if and only if the renaming succeeded; false otherwise
Note : Constructing the file object does NOT create a file on disk!
UPDATES : since @prasanth said question is about save as feature I am adding that part
For save as feature
reference from duplicate post
FileChannel src = new FileInputStream(file1).getChannel();
FileChannel dest = new FileOutputStream(file2).getChannel();
dest.transferFrom(src, 0, src.size());
// also close FileChannel objects

Community
- 1
- 1

Srinath Ganesh
- 2,496
- 2
- 30
- 60
-
-
"save an exisiting excel with a new name" means "RENAME" , Am I still wrong ?? Ill still add that code for 'save as' – Srinath Ganesh Sep 09 '13 at 06:00
-
Save As - Save the file with the new name. Note old file still exists. Rename - Rename the file name – prasanth Sep 09 '13 at 06:06
-