• Post Reply Bookmark Topic Watch Topic
  • New Topic

making a backup copy of a pdf on the fly

 
DC Dalton
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I actually feel kind of stupid asking this, the answer is probably right under my nose but the brain doesnt seem to want to cooperate today. Here's my quandry. My client has daily reports created every day for his business in pdf format (anywhere from 6 - 24 files). (Im using the iText package here). He wants a daily backup of all the days files created on the server JUST IN CASE. Is there anyway to create these backups without reading in the whole file & then writing it back out to a new backup version? Im thinking this should be a lot easier than Im making it out to be.....I literally want to "clone" the files into a different directory. Any & all help would be much appreciated.
[ November 17, 2002: Message edited by: DC Dalton ]
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably a bit late to reply to this, but...
As far as I know (and I'm pretty sure), there is no way to copy files in Java other than to open the existing file for reading and the new file for writing and to transfer the contents. You can do it with Input/OutputStreams, Reader/Writers or RandomAccessFile; suspect that the last of these may be fastest, if carefully coded.
To copy several files, you need to open the directory and get the files with File.listFiles(). Then do the above for each directory entry that you want to copy.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!