Example usage for java.util Scanner next

List of usage examples for java.util Scanner next

Introduction

In this page you can find the example usage for java.util Scanner next.

Prototype

public String next() 

Source Link

Document

Finds and returns the next complete token from this scanner.

Usage

From source file:Main.java

public static String convertStreamToString(InputStream is) {
    java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
    return s.hasNext() ? s.next() : "";
}

From source file:Main.java

public static String convertStreamToString(InputStream inputStream) {
    java.util.Scanner s = new java.util.Scanner(inputStream).useDelimiter("\\A");
    return s.hasNext() ? s.next() : "";
}

From source file:org.jboss.fuse.security.role.cxf.Client.java

protected static String inputStreamToString(InputStream is) {
    Scanner s = new Scanner(is).useDelimiter("\\A");
    return s.hasNext() ? s.next() : "";
}

From source file:net.acesinc.convergentui.content.TextHttpMessageConverter.java

static String convertStreamToString(java.io.InputStream is) {
    java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
    return s.hasNext() ? s.next() : "";
}

From source file:org.dspace.authority.rest.RESTConnector.java

public static String convertStreamToString(InputStream is) {
    Scanner s = new Scanner(is).useDelimiter("\\A");
    return s.hasNext() ? s.next() : "";
}

From source file:Main.java

/**
 * Reads a file relative to the dir this app was started from.
 * @param filename relative filename to load
 * @return entire file as a String/*w  w w.j av a  2s  .c  om*/
 * @throws FileNotFoundException if file not found!
 */
public static String readFile(String filename) throws FileNotFoundException {

    String startDir = System.getProperty("user.dir");
    File propertyFile = new File(startDir, filename);

    Scanner scan = new Scanner(new FileInputStream(propertyFile));
    scan.useDelimiter("\\Z");
    String content = scan.next();
    scan.close();

    return content;
}

From source file:com.aerofs.baseline.http.HttpUtils.java

public static String readStreamToString(InputStream in) throws IOException {
    Scanner scanner = new Scanner(in).useDelimiter("\\A");
    return scanner.hasNext() ? scanner.next() : "";
}

From source file:com.starit.diamond.server.utils.SystemConfig.java

public static void system_pause() {
    System.out.println("press ANY KEY to QUIT.");
    Scanner scanner = new Scanner(System.in);
    scanner.next();
}

From source file:org.rexify.eclipse.helper.InternetHelper.java

static public String convertStreamToString(InputStream is) {
    java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
    return s.hasNext() ? s.next() : "";
}

From source file:org.camunda.bpm.elasticsearch.util.JsonHelper.java

public static String readJsonFromClasspathAsString(String fileName) {
    InputStream inputStream = null;

    try {/*from  w w  w .j  ava2  s  .  co m*/
        inputStream = IoUtil.getResourceAsStream(fileName);
        if (inputStream == null) {
            throw new RuntimeException("File '" + fileName + "' not found!");
        }

        Scanner s = new java.util.Scanner(inputStream, "UTF-8").useDelimiter("\\A");
        return s.hasNext() ? s.next() : null;
    } finally {
        IoUtil.closeSilently(inputStream);
    }
}