Example usage for java.lang System in

List of usage examples for java.lang System in

Introduction

In this page you can find the example usage for java.lang System in.

Prototype

InputStream in

To view the source code for java.lang System in.

Click Source Link

Document

The "standard" input stream.

Usage

From source file:luisjosediez.Ejercicio2.java

static String inicializar() {

    String buzon = "";
    InputStreamReader flujo = new InputStreamReader(System.in);
    BufferedReader teclado = new BufferedReader(flujo);
    try {//from w  w w  . j a  va  2s  .co  m
        buzon = teclado.readLine();
    } catch (Exception e) {
        System.out.append("Entrada incorrecta");
    }
    return buzon;

}

From source file:formatMessage.VerifyInputScanner.java

/**
 * De verifyString methode is echt heel moeilijk want eignelijk is alles een string misschien moeten we hier anders op testen 
 * door bijvoorbeeld te stellen dat er geen cijfers inmogen? 
 * @return // w  w  w .  j a v  a 2s .co  m
 */
public static String verifyString() {

    while (true) {
        Scanner input = new Scanner(System.in);
        try {
            String verified = input.nextLine();

            return verified;
        } catch (InputMismatchException e) {
            System.out.println("Ongeldige invoer. Probeer opnieuw.");

        }
    }
}

From source file:dslistevents.DSListEvents.java

public static void main(String[] args) {

    DSListEvents test = new DSListEvents();
    test.processArgs(args);/*from   w w w.ja va 2s  .  c o  m*/

    try {
        if (test.dsLogin()) {
            // Get an admin session
            DSAdminSession adminSession = test.dssession.getAdminSession();
            // Add an event listener
            //adminSession.addEventListener( test, DSEventObj.ALL_EVENTS );
            test.dssession.addEventListener(test, DSEventObj.ALL_EVENTS);

        }
    } catch (DSException dse) {
        dse.printStackTrace();
    }

    // Wait for a key to be pressed
    InputStreamReader is = new InputStreamReader(System.in);
    System.out.println("Press CTRL C to exit....");
}

From source file:de.micromata.genome.gwiki.jetty.CmdLineInput.java

public static String readLine() {
    StringBuilder sb = new StringBuilder();
    try {// w w  w .  j av a2  s .c o m
        do {
            int c = System.in.read();
            if (c == '\n') {
                String s = sb.toString();
                if (s.length() > 0 && s.charAt(s.length() - 1) == '\r') {
                    s = s.substring(0, s.length() - 1);
                }
                return s;
            }
            sb.append((char) c);
        } while (true);
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:aldenjava.opticalmapping.Cigar.java

public static void main(String[] args) throws IOException {

    System.out.println("Please enter the cigar string to convert:");
    StringBuilder cigar = new StringBuilder();
    int c = System.in.read();
    while (c != -1) {
        cigar.append((char) c);
        if (System.in.available() == 0)
            break;
        c = System.in.read();/* w  w  w. j ava  2 s. c om*/
    }

    String precigar = Cigar.convertpreCIGAR(cigar.toString().trim());
    System.out.println("The precigar is:");
    System.out.println(precigar);
}

From source file:com.liferay.blade.cli.util.Prompter.java

public static boolean confirm(String question) {
    return confirm(question, System.in, System.out, Optional.empty());
}

From source file:com.liferay.blade.cli.util.Prompter.java

public static boolean confirm(String question, boolean defaultAnswer) {
    return confirm(question, System.in, System.out, Optional.of(defaultAnswer));
}

From source file:com.rjfun.cordova.httpd.NanoHTTPD.java

/**
 * Starts as a standalone file server and waits for Enter.
 *//*w  w  w. ja  v  a 2 s  .  com*/
public static void main(String[] args) {
    PrintStream myOut = System.out;
    PrintStream myErr = System.err;

    myOut.println("NanoHTTPD 1.25 (C) 2001,2005-2011 Jarno Elonen and (C) 2010 Konstantinos Togias\n"
            + "(Command line options: [-p port] [-d root-dir] [--licence])\n");

    // Defaults
    int port = 80;
    File wwwroot = new File(".").getAbsoluteFile();

    // Show licence if requested
    for (int i = 0; i < args.length; ++i)
        if (args[i].equalsIgnoreCase("-p"))
            port = Integer.parseInt(args[i + 1]);
        else if (args[i].equalsIgnoreCase("-d"))
            wwwroot = new File(args[i + 1]).getAbsoluteFile();
        else if (args[i].toLowerCase().endsWith("licence")) {
            myOut.println(LICENCE + "\n");
            break;
        }

    try {
        new NanoHTTPD(port, new AndroidFile(wwwroot.getPath()));
    } catch (IOException ioe) {
        myErr.println("Couldn't start server:\n" + ioe);
        System.exit(-1);
    }

    myOut.println("Now serving files in port " + port + " from \"" + wwwroot + "\"");
    myOut.println("Hit Enter to stop.\n");

    try {
        System.in.read();
    } catch (Throwable t) {
    }
}

From source file:edu.stanford.muse.email.VerifyEmailSetup.java

public static Pair<Boolean, String> run() {
    PrintStream savedOut = System.out;
    InputStream savedIn = System.in;

    try {/*from w w  w  . j av  a 2 s  .co m*/
        // Get a Properties object
        Properties props = System.getProperties();

        // Get a Session object
        Session session = Session.getInstance(props, null);
        session.setDebug(true);
        String filename = System.getProperty("java.io.tmpdir") + File.separatorChar + "verifyEmailSetup";
        PrintStream ps = new PrintStream(new FileOutputStream(filename));
        System.setOut(ps);
        System.setErr(ps);

        // Get a Store object
        Store store = null;
        store = session.getStore("imaps");
        store.connect("imap.gmail.com", 993, "checkmuse", ""); // not the real password. unfortunately, the checkmuse a/c will get blocked by google.
        //           Folder folder = store.getFolder("[Gmail]/Sent Mail");
        //           int totalMessages = folder.getMessageCount();
        // System.err.println (totalMessages + " messages!");
        ps.close();
        String contents = Util.getFileContents(filename);
        System.out.println(contents);
        return new Pair<Boolean, String>(Boolean.TRUE, contents);
    } catch (AuthenticationFailedException e) {
        /* its ok if auth failed. we only want to check if IMAPS network route is blocked.
         when network is blocked, we'll get something like
        javax.mail.MessagingException: No route to host; 
        nested exception is: 
        java.net.NoRouteToHostException: No route to host 
        ...
        */
        log.info("Verification succeeded: " + Util.stackTrace(e));
        return new Pair<Boolean, String>(Boolean.TRUE, "");
    } catch (Exception e) {
        log.warn("Verification failed: " + Util.stackTrace(e));
        return new Pair<Boolean, String>(Boolean.FALSE, e.toString()); // stack track reveals too much about our code... Util.stackTrace(e));         
    } finally {
        System.setOut(savedOut);
        System.setIn(savedIn);
    }
}