Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    public static boolean putFileContent(File file, InputStream inputStream) throws IOException {
        if (!file.exists() && !file.createNewFile()) {
            return false;
        }

        byte[] buffer = new byte[1024];
        FileOutputStream fileOutputStream = new FileOutputStream(file);

        for (int len; (len = inputStream.read(buffer)) != -1;) {
            fileOutputStream.write(buffer, 0, len);
        }

        inputStream.close();
        fileOutputStream.close();
        return true;
    }
}