benou | Code :
- package utils;
- import java.io.*;
- public class StreamUtils {
- public static void copy (final InputStream inStream, final OutputStream outStream, final int bufferSize) throws IOException {
- final byte[] buffer = new byte[bufferSize];
- int nbRead;
- while ((nbRead = inStream.read(buffer)) != -1) {
- outStream.write(buffer, 0, nbRead);
- }
- }
- public static void copy (final File from, final File to) throws IOException {
- final InputStream inStream = new FileInputStream(from);
- final OutputStream outStream = new FileOutputStream(to);
- copy(inStream, outStream, (int) Math.min(from.length(), 4*1024));
- inStream.close();
- outStream.close();
- }
- }
|
edit : closage de stream !
edit2 : encore une coorrection de bug ---------------
ma vie, mon oeuvre - HomePlayer
|