Here you can find the source of readFileIntoLinesOfLongs(File file)
public static List<Long> readFileIntoLinesOfLongs(File file)
//package com.java2s; /**/*from w w w. j ava 2s. co m*/ * <p> * Utilities for manipulating Paths, Files, Directories, etc. * </p> * <p> * <span class="BSDLicense"> This software is distributed under the <a * href="http://hci.stanford.edu/research/copyright.txt">BSD License</a>.</span> * </p> * * @author <a href="http://graphics.stanford.edu/~ronyeh">Ron B Yeh</a> (ronyeh(AT)cs.stanford.edu) */ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Main { public static List<Long> readFileIntoLinesOfLongs(File file) { List<String> lines = readFileIntoLines(file); List<Long> dest = new ArrayList<Long>(); for (String s : lines) { dest.add(Long.parseLong(s)); } return dest; } /** * Reads a file into a list of Strings * * @param file * @return * @throws IOException */ public static List<String> readFileIntoLines(File file) { List<String> lines = new ArrayList<String>(); try { FileInputStream fis = new FileInputStream(file); BufferedReader read = new BufferedReader(new InputStreamReader(fis)); String line; while ((line = read.readLine()) != null) { lines.add(line); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return lines; } }