This is the code you are looking for
Code:
try (
/ / Create the file:
dst.createNewFile ();
/ / Opening streams
sfl = new java.io.FileInputStream (source);
desfl = new java.io.FileOutputStream (dst);
/ / Reading by segment 0.5Mo
byte bf [] = new byte [512 * 1024];
int lec;
while ((lec srfl.read = (bf))! = -1) (
desfl.write (bf, 0, lec);
)
/ / Copy success
rst = true;
) Catch (java.io.FileNotFoundException f) (
) Catch (java.io.IOException e) (
) Finally (
/ / Whatever happens, we close the stream
try (
srfl.close ();
) Catch (Exception e) ()
try (
desfl.close ();
) Catch (Exception e) ()
)
return (rst);
)
Bookmarks