Here you can find the source of copyFile(final String sSource, final String sDest)
Parameter | Description |
---|---|
sSource | a parameter |
sDest | a parameter |
public static final boolean copyFile(final String sSource, final String sDest)
//package com.java2s; //License from project: LGPL import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; public class Main { /**// w ww .jav a2 s. co m * Copy the file contents. * * @param sSource * @param sDest * @return true if everything went ok, false if there was a problem */ public static final boolean copyFile(final String sSource, final String sDest) { InputStream is = null; OutputStream os = null; try { is = new FileInputStream(sSource); os = new FileOutputStream(sDest); final byte[] buff = new byte[16 * 1024]; int len; while ((len = is.read(buff)) > 0) { os.write(buff, 0, len); } os.flush(); os.close(); os = null; is.close(); is = null; return true; } catch (final Throwable t) { return false; } finally { if (is != null) { try { is.close(); } catch (final Exception e) { // improbable, ignore } } if (os != null) { try { os.close(); } catch (final Exception e) { // improbable, ignore } } } } }