Пример #1
0
 public static void writeFileAndClose(File file, InputStream in) {
   OutputStream out = null;
   try {
     out = new FileOutputStream(file);
     byte[] buffer = new byte[1024];
     int len = in.read(buffer);
     while (len > 0) {
       out.write(buffer, 0, len);
       len = in.read(buffer);
     }
   } catch(IOException e) {
     throw Log.errRTExcept(e);
   } finally {
     close(in, out);
   }
 }
Пример #2
0
 public static void readFile(File file, OutputStream out) {
   BufferedInputStream in = null;
   try {
     in = new BufferedInputStream(new FileInputStream(file));
     byte[] buffer = new byte[1024];
     while( true ) {
       int count = in.read(buffer);
       if( count == -1 )
         break;
       out.write(buffer, 0, count);
     }
   } catch(IOException e) {
     throw Log.errRTExcept(e);
   } finally {
     close(in);
   }
 }