Thread: I Need Help!
View Single Post
  #2 (permalink)  
Old 02-02-2008, 02:18 AM
JAdmin JAdmin is offline
Member
 
Join Date: Jan 2008
Posts: 20
JAdmin is on a distinguished road
Here is a file copy example

Code:
boolean fileCopied = false; InputStream in = null; OutputStream out = null; String sepr = System.getProperty("file.separator"); try { in = new FileInputStream(path+sepr+srcFileName); File newFile = new File(path+sepr+targetFileName); out = new FileOutputStream(path+sepr+targetFileName); byte[] buffer = new byte[2048]; while (true) { synchronized (buffer) { int length = in.read(buffer); if (length != -1) { out.write(buffer, 0, length); } else break; } } File oldFile = new File(path+sepr+srcFileName); fileCopied = newFile.exists(); } catch(Throwable t){ //handle exceptions here. } finally { try{ if (in != null) { in.close();} if (out != null) { out.close(); } }catch(Throwable t1){} } return fileCopied;

Hope this helps
__________________
Sincerely, Your friends at
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Reply With Quote