Java URL Load readResource(URL resource)

Here you can find the source of readResource(URL resource)

Description

read Resource

License

LGPL

Declaration

public static String readResource(URL resource) throws IOException 

Method Source Code


//package com.java2s;
/*/*from   w  w w  .  j  ava 2 s  . co m*/
 * Hibernate OGM, Domain model persistence for NoSQL datastores
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later
 * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
 */

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

public class Main {
    private static final String FILE_DELIMITER = "\\A";

    public static String readResource(URL resource) throws IOException {
        try (InputStream is = resource.openStream()) {
            Scanner s = new Scanner(is).useDelimiter(FILE_DELIMITER);
            return s.hasNext() ? s.next() : "";
        }
    }
}

Related

  1. readProperties(final URL url)
  2. readProperties(final URL url)
  3. readProperties(URL resource)
  4. readPropertyFile(URL url)
  5. readResource(final URL filename)
  6. readServicesFromUrl(Collection list, URL url)
  7. readSqlStatements(URL url)
  8. readStopwordsURL(URL url, boolean lowercase)
  9. readStringFromUrl(URL url)