Example usage for java.io BufferedReader readLine

List of usage examples for java.io BufferedReader readLine

Introduction

In this page you can find the example usage for java.io BufferedReader readLine.

Prototype

public String readLine() throws IOException 

Source Link

Document

Reads a line of text.

Usage

From source file:PipedCharacters.java

public static void readStuff(Reader rawIn) {
    try {/*  w  w w.j a  va  2s. c o m*/
        BufferedReader in = new BufferedReader(rawIn);

        String line;
        while ((line = in.readLine()) != null) {
            System.out.println("read line: " + line);
        }

        System.out.println("Read all data from the pipe");
    } catch (IOException x) {
        x.printStackTrace();
    }
}

From source file:org.datacleaner.util.http.CASMonitorHttpClientTest.java

private static void doRequest(CASMonitorHttpClient client, HttpUriRequest req) throws Exception {
    System.out.println("REQUESTING: " + req.getURI());

    final HttpResponse response = client.execute(req);

    final StatusLine statusLine = response.getStatusLine();
    System.out.println("\tStatus: " + statusLine.getStatusCode() + " - " + statusLine.getReasonPhrase());

    final HttpEntity entity = response.getEntity();
    final InputStream in = entity.getContent();

    final BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    String line = reader.readLine();
    while (line != null) {
        System.out.println("\t" + line);
        line = reader.readLine();//from  ww  w  . j  a  v  a2s . c o m
    }
}

From source file:Main.java

public static String dumpFile(String filename) {
    String line = "";
    try {/*from  ww w .  j av  a2  s. c o  m*/
        Process ifc = Runtime.getRuntime().exec("cat " + filename);
        BufferedReader bis = new BufferedReader(new InputStreamReader(ifc.getInputStream()));
        line = bis.readLine();
        ifc.destroy();

    } catch (java.io.IOException e) {
        return new String("");
    }

    return line;
}

From source file:Main.java

public static String getDns() {

    try {/*  w w  w  . j ava  2s . c  o  m*/
        Process p = Runtime.getRuntime().exec("getprop net.dns1");
        BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String dns = in.readLine();
        return dns;
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static String read(InputStream in) throws IOException {
    StringBuilder sb = new StringBuilder();
    BufferedReader r = new BufferedReader(new InputStreamReader(in), 1000);
    for (String line = r.readLine(); line != null; line = r.readLine()) {
        sb.append(line);//ww w .  j  a va  2 s  .  co  m
    }
    in.close();
    return sb.toString();
}

From source file:atualizador.Atualizador.java

private static void VerificarAtualizacao(String MD5FileName, String SistemaFileName, String DiretorioFTP) {
    try {/*from  w  w  w .ja  va2  s  .  com*/

        FTPDownload(MD5FileName, DiretorioFTP); //Arquivo TXT com o MD5

        //Le o valor do arquivo
        FileReader arq = new FileReader(MD5FileName);

        BufferedReader lerArq = new BufferedReader(arq);
        String linha = lerArq.readLine();

        String Md5FPT = linha;
        String Md5Local = geraHash(new File(SistemaFileName)); //Mudar o file name 
        if (!ValidaVersao(Md5FPT, Md5Local)) {
            System.out.println("Atualizando");
            FTPDownload(SistemaFileName, DiretorioFTP);
        }

    } catch (NoSuchAlgorithmException | FileNotFoundException ex) {
        Logger.getLogger(Atualizador.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(Atualizador.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.hp.test.framework.jmeterTests.GetJmeterTestCaseFileList.java

private static void printLines(String name, InputStream ins) throws Exception {
    String line = null;//  w ww  .j a v  a 2  s.c om
    BufferedReader in = new BufferedReader(new InputStreamReader(ins));
    while ((line = in.readLine()) != null) {
        System.out.println(name + " " + line);
    }
}

From source file:Main.java

private static boolean checkRootMethod3() {
    Process process = null;//from ww  w .  ja  v  a  2s.  c o m
    try {
        process = Runtime.getRuntime().exec(new String[] { "/system/xbin/which", "su" });
        BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
        if (in.readLine() != null)
            return true;
        return false;
    } catch (Throwable t) {
        return false;
    } finally {
        if (process != null)
            process.destroy();
    }
}

From source file:Main.java

private static boolean checkRootMethod3() {
    Process process = null;/*from   w w  w .  j a v a 2s. c o  m*/
    try {
        process = Runtime.getRuntime().exec(new String[] { "/system/xbin/which", "su" });
        BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
        return in.readLine() != null;
    } catch (Throwable t) {
        return false;
    } finally {
        if (process != null)
            process.destroy();
    }
}