Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.BufferedReader;

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

import java.io.PushbackInputStream;

public class Main {
    public static BufferedReader readMap(InputStream in) throws IOException {

        PushbackInputStream pushback = new PushbackInputStream(in, 3);

        int first = pushback.read();
        if (first == 0xEF) {
            int second = pushback.read();
            if (second == 0xBB) {
                int third = pushback.read();
                if (third == 0xBF) {
                    return new BufferedReader(new InputStreamReader(pushback, "UTF-8"));
                }
                pushback.unread(third);
            }
            pushback.unread(second);
        }
        pushback.unread(first);

        return new BufferedReader(new InputStreamReader(pushback, "ISO-8859-1"));
    }
}