Here you can find the source of copyFileFromAssets(InputStream inputStream, String pathToWrite)
public static void copyFileFromAssets(InputStream inputStream, String pathToWrite)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static void copyFileFromAssets(InputStream inputStream, String pathToWrite) { OutputStream outputStream = null; try {//from ww w . j av a 2 s . c o m File newFile = new File(pathToWrite); if (!newFile.exists()) { newFile.createNewFile(); } // write the inputStream to a FileOutputStream outputStream = new FileOutputStream(new File(pathToWrite)); int read = 0; byte[] bytes = new byte[1024]; while ((read = inputStream.read(bytes)) != -1) { outputStream.write(bytes, 0, read); } } catch (IOException e) { e.printStackTrace(); } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } if (outputStream != null) { try { // outputStream.flush(); outputStream.close(); } catch (IOException e) { e.printStackTrace(); } } } } }