Java Scanner Read load(File in)

Here you can find the source of load(File in)

Description

Used to load the entire file into String object

License

Open Source License

Parameter

Parameter Description
in FIle to be loaded

Exception

Parameter Description
IOException IO errors

Return

FIle content

Declaration

public static String load(File in) throws IOException 

Method Source Code

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

import java.io.File;

import java.io.IOException;

import java.util.Scanner;

public class Main {
    /**/*from w w  w  . jav  a  2s. c om*/
    * Used to load the entire file into String object
    * @param in FIle to be loaded
    * @return FIle content
    * @throws IOException IO errors
    */
    public static String load(File in) throws IOException {
        Scanner sc = new Scanner(in);
        StringBuilder sb = new StringBuilder();
        while (sc.hasNextLine()) {
            sb.append(sc.nextLine()).append("\n");
        }
        return sb.toString();
    }
}

Related

  1. getStreamLines(final InputStream is)
  2. getThreadScanner()
  3. load(Class cls, String location)
  4. load(final String fileName)
  5. load(InputStream in, int elementCountOverride)
  6. loadAWSCredentails(String file_path)
  7. loadBooleanArray(BufferedReader in)