Java Scanner Read loadBooleanArray(BufferedReader in)

Here you can find the source of loadBooleanArray(BufferedReader in)

Description

load Boolean Array

License

Open Source License

Declaration

public static boolean[] loadBooleanArray(BufferedReader in) 

Method Source Code


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

import java.io.BufferedReader;

import java.io.IOException;

import java.util.Scanner;

public class Main {
    public static boolean[] loadBooleanArray(BufferedReader in) {
        try {/*from   ww w.java2 s.  c  om*/
            int dim = Integer.parseInt(in.readLine());
            String[] vals = in.readLine().split("\\s+");
            boolean[] ret = new boolean[dim];
            for (int i = 0; i < ret.length; i++) {
                ret[i] = Boolean.parseBoolean(vals[i]);
            }
            return ret;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static boolean[] loadBooleanArray(Scanner reader) {
        int dim = reader.nextInt();
        boolean[] ret = new boolean[dim];
        for (int i = 0; i < dim; i++) {
            ret[i] = Boolean.parseBoolean(reader.next());
        }
        return ret;
    }
}

Related

  1. load(Class cls, String location)
  2. load(File in)
  3. load(final String fileName)
  4. load(InputStream in, int elementCountOverride)
  5. loadAWSCredentails(String file_path)
  6. loadConf()
  7. loadDoubleArray(Scanner reader)
  8. loadDoubleMatrix(Scanner reader)
  9. loadIntArray(Scanner reader)