Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.File;
import java.io.FileOutputStream;

import java.io.InputStream;

public class Main {
    private static int BUFFER_SIZE = 4096;

    private static void copyInputStreamToFile(InputStream is, File file) throws Exception {
        int bytes;
        byte[] buf = new byte[BUFFER_SIZE];

        FileOutputStream fos = new FileOutputStream(file);
        while ((bytes = is.read(buf, 0, BUFFER_SIZE)) > 0) {
            fos.write(buf, 0, bytes);
        }

        is.close();
        fos.close();
    }
}