Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.IOException;
import java.io.StringReader;

public class Main {
    public static boolean readBoolean(StringReader reader, char delimiter) {
        String bool = readString(reader, delimiter);
        return bool.equalsIgnoreCase("Y") || bool.equalsIgnoreCase("true");
    }

    public static String readString(StringReader sr, char delimiter) {
        try {
            StringBuilder sb = new StringBuilder();
            char c;
            while ((c = (char) sr.read()) != (char) -1) {
                if (c == '\\') {
                    // This is an escape character. Jump past to the next char.
                    sb.append((char) sr.read());
                } else if (c == delimiter) {
                    break;
                } else {
                    sb.append(c);
                }
            }
            return sb.toString();
        } catch (IOException e) {
            // Cannot happen as there is no IO here - just a read from a string
            throw new RuntimeException("Unexpected IOException", e);
        }

    }
}