Java Scanner Read readFile(Class ownerClass, String fileName)

Here you can find the source of readFile(Class ownerClass, String fileName)

Description

read File

License

Open Source License

Declaration

public static String readFile(Class ownerClass, String fileName) throws IOException 

Method Source Code


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

import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;

public class Main {
    public static String readFile(Class ownerClass, String fileName) throws IOException {
        String resourcePath = ownerClass.getSimpleName() + "/" + fileName;
        try (InputStream inputStream = ownerClass.getResourceAsStream(resourcePath);
                Scanner scanner = new Scanner(inputStream)) {
            scanner.useDelimiter("\\A");
            return scanner.hasNext() ? scanner.next() : "";
        }//  w w  w  . j  a v a2s  .c o m
    }
}

Related

  1. loadTimeseries(File file, String delimeter, int _amountOfLines)
  2. read()
  3. read(Class clazz, String f)
  4. readArr(Scanner in, int n)
  5. readCQLFile(String cqlFileName)
  6. readFile(File f)
  7. readFile(File f)
  8. readFile(File f)
  9. readFile(File file)