Java Scanner Read loadIntArray(Scanner reader)

Here you can find the source of loadIntArray(Scanner reader)

Description

load Int Array

License

Open Source License

Declaration

public static int[] loadIntArray(Scanner reader) 

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 int[] loadIntArray(Scanner reader) {
        int dim = reader.nextInt();
        int[] ret = new int[dim];
        for (int i = 0; i < dim; i++) {
            ret[i] = Integer.parseInt(reader.next());
        }/*from   www  .j av a2s  . c o m*/
        return ret;
    }

    public static int[] loadIntArray(BufferedReader in) {
        try {
            int dim = Integer.parseInt(in.readLine());
            String[] vals = in.readLine().split("\\s+");
            int[] ret = new int[dim];
            for (int i = 0; i < ret.length; i++) {
                ret[i] = Integer.parseInt(vals[i]);
            }
            return ret;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. loadAWSCredentails(String file_path)
  2. loadBooleanArray(BufferedReader in)
  3. loadConf()
  4. loadDoubleArray(Scanner reader)
  5. loadDoubleMatrix(Scanner reader)
  6. loadNDimDoubleMatrix(Scanner reader, int numberOfDim, Object nmatrix)
  7. loadNDimDoubleMatrixRec(Scanner reader, int[] dim, Object nmatrix)
  8. loadSentencesMap(String path)
  9. loadSolution(File file)