Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import java.io.IOException;
import java.io.InputStream;

import java.net.URL;

import java.util.zip.ZipEntry;

import java.util.zip.ZipFile;

public class Main {
    public static FileInputStream inputStream(File file) {
        try {
            return new FileInputStream(file);
        } catch (final FileNotFoundException e) {
            throw new IllegalArgumentException("File " + file + " not found.", e);
        }
    }

    public static InputStream inputStream(ZipFile zipFile, ZipEntry entry) {
        try {
            return zipFile.getInputStream(entry);
        } catch (final FileNotFoundException e) {
            throw new IllegalArgumentException("File " + zipFile + " not found.", e);
        } catch (final IOException e) {
            throw new RuntimeException("File " + zipFile + " not found.", e);
        }
    }

    public static InputStream inputStream(URL file) {
        try {
            return file.openStream();
        } catch (final IOException e) {
            throw new RuntimeException(e);
        }
    }
}