Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright (c) 2010, 2011 AnjLab
 * 
 * This file is part of 
 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem.
 * 
 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem 
 * is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem
 * is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with
 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem.
 * If not, see <http://www.gnu.org/licenses/>.
 */

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

public class Main {
    /**
     * There are should be at least 4 bytes in input stream. Otherwise result may be not defined.
     * If input stream contains no more data, method return {@link Integer#MAX_VALUE}.
     * 
     * @param input
     * @return Next Integer from input stream.
     * @throws IOException
     */
    public static int readInt(InputStream input) throws IOException {
        int value = Integer.MAX_VALUE;
        int buf;
        if ((buf = input.read()) != -1) {
            value = buf;
            value = value | (input.read() << 8);
            value = value | (input.read() << 16);
            value = value | (input.read() << 24);
        }
        return value;
    }
}