Java tutorial
//package com.java2s; /** * WazeUtils.java * This class represents general utilities for the application handling * * * LICENSE: * * Copyright 2009 @author Alex Agranovich * * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * SYNOPSYS: * * @see */ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.nio.channels.FileChannel; import android.util.Log; public class Main { /************************************************************************************************* * Copies the resources to the SD card * */ public static void CopyFile() { // Log.i( "CopyResources2SD", "Starting t copy the resources" ); // String resDir = FreeMapResources.mAppDir; // String dstDir = FreeMapResources.mSDCardDir; // // Copying // CopyDir( resDir, dstDir ); } private static void CopyFile(String srcPath, String dstPath) { FileChannel srcChannel = null; FileChannel dstChannel = null; try { // Open files srcChannel = (new FileInputStream(srcPath)).getChannel(); dstChannel = (new FileOutputStream(dstPath)).getChannel(); // Transfer the data dstChannel.transferFrom(srcChannel, 0, srcChannel.size()); // Close the files if (srcChannel != null) { srcChannel.close(); } if (dstChannel != null) { dstChannel.close(); } } catch (FileNotFoundException ex) { Log.i("CopyFile", "File not found " + ex.getMessage()); ex.printStackTrace(); } catch (IOException ex) { Log.i("CopyFile", "Transfer data error " + ex.getMessage()); ex.printStackTrace(); } } }