Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Copy/moving a file from one location to Server location.

 
shiva valanukonda
Greenhorn
Posts: 26
Hibernate jQuery Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to copy/move an Excel file from source location to Server location.
I supposed to do it manually by uploading the file using browse button in Server url.
Can we do it automatically using java code by eliminating this browse mechanism.
Please give me your valuable suggestions on this.

Thanks in advance
VSRK
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could poll a known directory for the Excel files, and transfer them as they appear. There can be issues with synchronization though. For example, your process could see the Excel file and try to start transferring it before it has been fully created, or while its still being edited. One common trick is to write the file with a different name, like .myfile.xls, then rename it to myfile.xls when you're ready for it to transfer. Another trick is to keep a .lock file in the directory, and delete it when all the files in the directory are ready.

This question isn't specifically about I/O streams, so I'm going to move it over to general Java, where you'll probably get a lot more useful suggestions!
 
Carey Brown
Ranch Hand
Posts: 1379
16
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Windows at least, you can't "move" (renameTo()) files across file systems but you can copy them and then delete the original.
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:In Windows at least, you can't "move" (renameTo()) files across file systems but you can copy them and then delete the original.

Interesting. I've been able to successfully do just that multiple times, even to different physical hard drives or to a Windows share.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic