From: minkee.lee Date: Wed, 29 Oct 2014 10:35:57 +0000 (+0900) Subject: Utility: Add file copy function. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fe922e4fd86947be2540e77316cbb1c5bdf4dc5e;p=sdk%2Femulator%2Femulator-manager.git Utility: Add file copy function. Change-Id: I688a1c64797de9f9ddf36e44ee03b83e9ea57e27 Signed-off-by: minkee.lee --- diff --git a/common-project/src/org/tizen/emulator/manager/resources/FilePathResources.java b/common-project/src/org/tizen/emulator/manager/resources/FilePathResources.java index 3c26429..e932904 100644 --- a/common-project/src/org/tizen/emulator/manager/resources/FilePathResources.java +++ b/common-project/src/org/tizen/emulator/manager/resources/FilePathResources.java @@ -482,4 +482,8 @@ public class FilePathResources { public static String getEmulatorPath() { return emulatorPath; } + + public static String getResourceSuffix() { + return resource_suffix; + } } diff --git a/common-project/src/org/tizen/emulator/manager/vms/helper/HelperClass.java b/common-project/src/org/tizen/emulator/manager/vms/helper/HelperClass.java index 8940d0e..489ff5e 100644 --- a/common-project/src/org/tizen/emulator/manager/vms/helper/HelperClass.java +++ b/common-project/src/org/tizen/emulator/manager/vms/helper/HelperClass.java @@ -30,7 +30,12 @@ package org.tizen.emulator.manager.vms.helper; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; import java.net.ConnectException; import java.net.Inet6Address; @@ -243,5 +248,45 @@ public class HelperClass { return loaclIPAddress; } + public static void FileCopy(File source, File dest) throws IOException { + + FileInputStream inputStream = null; + FileOutputStream outputStream = null; + BufferedInputStream bin = null; + BufferedOutputStream bout = null; + + try { + inputStream = new FileInputStream(source); + outputStream = new FileOutputStream(dest); + + bin = new BufferedInputStream(inputStream); + bout = new BufferedOutputStream(outputStream); + + int bytesRead = 0; + byte[] buffer = new byte[1024]; + while ((bytesRead = bin.read(buffer, 0, 1024)) != -1) { + bout.write(buffer, 0, bytesRead); + } + + } catch (IOException e) { + throw e; + + } finally { + if (bout != null) { + bout.close(); + } + if (bin != null) { + bin.close(); + } + if (outputStream != null) { + outputStream.close(); + } + if (inputStream != null) { + inputStream.close(); + } + } + + } + }