Example usage for java.lang Boolean parseBoolean

List of usage examples for java.lang Boolean parseBoolean

Introduction

In this page you can find the example usage for java.lang Boolean parseBoolean.

Prototype

public static boolean parseBoolean(String s) 

Source Link

Document

Parses the string argument as a boolean.

Usage

From source file:Main.java

public static void main(String[] args) {
    System.out.println(Boolean.parseBoolean("true"));
}

From source file:Main.java

public static void main(String[] args) {
    // Parsing string "true" will result boolean true
    boolean boolA = Boolean.parseBoolean("true");
    System.out.println("boolA = " + boolA);

    // Parsing string "TRUE" also resutl boolean true
    boolean boolB = Boolean.parseBoolean("TRUE");
    System.out.println("boolB = " + boolB);

}

From source file:Main.java

public static void main(String[] args) {
    String strBoolean = "true";

    //String to boolean conversion
    boolean theValue = Boolean.parseBoolean(strBoolean);

    System.out.println(theValue);
}

From source file:Main.java

public static void main(String[] args) {
    // Using constructors
    Boolean b1True = new Boolean(true);
    Boolean b2True = new Boolean("true");
    Boolean b3True = new Boolean("tRuE");
    Boolean b4False = new Boolean("false");
    Boolean b5False = new Boolean("how  is this"); // false

    // Using the factory methods
    Boolean b6True = Boolean.valueOf(true);
    Boolean b7True = Boolean.valueOf("true");
    Boolean b8True = Boolean.valueOf("tRuE");
    Boolean b9False = Boolean.valueOf("false");
    Boolean b10False = Boolean.valueOf("how is this"); // false

    // Getting a boolean value from a Boolean object
    boolean bbTrue = b8True.booleanValue();

    boolean bTrue = Boolean.parseBoolean("true");
    boolean bFalse = Boolean.parseBoolean("This string evaluates to false");

    Boolean bcTrue = Boolean.TRUE;
    Boolean bcFalse = Boolean.FALSE;

    System.out.println("bcTrue = " + bcTrue);
    System.out.println("bcFalse = " + bcFalse);
}

From source file:uk.ac.ebi.ep.sitemap.main.SiteMapMain.java

public static void main(String... args) throws Exception {

    //////////////comment here ///////////////////////
    //        args = new String[4];
    //        //String dbConfig = "ep-mm-db-enzdev";
    //        //String dbConfig = "ep-mm-db-enzprel";
    //        String userHome = System.getProperty("user.home");
    //        String filename = "SiteMap";
    //        String testing = "true";
    //        //w  w w.  j  av  a 2 s.  c  o  m
    //               
    //        args[0] = "vezpdev";
    //        args[1] = userHome;
    //        args[2] = filename;
    //        args[3] = testing;
    //////////////uncomment for testing parameters only ///////////////////////          
    if (args == null) {
        System.out.println("Please provide required parameters");
        System.exit(0);
    }

    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.getEnvironment().setActiveProfiles(args[0]);
    context.scan("uk.ac.ebi.ep.data.dataconfig");
    context.refresh();

    UniprotEntryService service = context.getBean(UniprotEntryService.class);

    SiteMapGenerator siteMapGenerator = new EnzymePortalSiteMap(service);
    boolean testMode = Boolean.parseBoolean(args[3]);
    siteMapGenerator.generateSitemap(args[1], args[2], testMode);

}

From source file:com.ibm.rdf.store.sparql11.DB2RDFQuery.java

public static void main(String[] args) {
    Options options = new Options();

    try {//from   w  ww .  j av  a 2  s.  c  om
        // create Options object
        options.addOption("jdbcurl", true, "jdbc url");
        options.addOption("schema", true, "schema name");
        options.addOption("kb", true, "knowledge base");
        options.addOption("username", true, "db user name");
        options.addOption("password", true, "db password");
        options.addOption("queryFile", true, "query file");
        options.addOption("defaultUnionGraph", false, "default Union Graph semantics");

        CommandLineParser parser = new GnuParser();
        CommandLine cmd = parser.parse(options, args);
        boolean defUnion = cmd.hasOption("defaultUnionGraph")
                ? Boolean.parseBoolean(cmd.getOptionValue("defaultUnionGraph"))
                : false;
        DB2TestData data = new DB2TestData(cmd.getOptionValue("jdbcurl"), cmd.getOptionValue("kb"),
                cmd.getOptionValue("username"), cmd.getOptionValue("password"),
                cmd.getOptionValue("schemaName"), defUnion);

        DB2RDFQuery q = new DB2RDFQuery(new DB2Engine(), data);
        q.executeQuery(cmd.getOptionValue("queryFile"));
    } catch (Exception e) {
        e.printStackTrace();
        HelpFormatter help = new HelpFormatter();
        help.printHelp("DB2RDFQuery", options);
    }
}

From source file:edu.snu.leader.discrete.simulator.Main.java

public static void main(String[] args) {
    System.setProperty("sim-properties", "cfg/sim/discrete/sim-properties.parameters");

    _simulationProperties = MiscUtils.loadProperties("sim-properties");

    String stringShouldRunGraphical = _simulationProperties.getProperty("run-graphical");
    Validate.notEmpty(stringShouldRunGraphical, "Run graphical option required");
    shouldRunGraphical = Boolean.parseBoolean(stringShouldRunGraphical);

    String stringTotalRuns = _simulationProperties.getProperty("run-count");
    Validate.notEmpty(stringTotalRuns, "Run count required");
    totalRuns = Integer.parseInt(stringTotalRuns);

    if (!shouldRunGraphical) {
        // run just text
        for (int run = 1; run <= totalRuns; run++) {
            System.out.println("Run " + run);
            System.out.println();

            // create and initialize simulator
            Simulator simulator = new Simulator(run);
            _simulationProperties.put("current-run", String.valueOf(run));
            simulator.initialize(_simulationProperties);
            // run it
            simulator.execute();//from  ww w.  j av  a2s .  c  o m
        }
    } else {
        // run graphical
        DebugLocationsStructure db = new DebugLocationsStructure("Conflict Simulation", 800, 600, 60);
        _simulationProperties.put("current-run", String.valueOf(1));
        db.initialize(_simulationProperties, 1);
        db.run();
    }
}

From source file:edu.cmu.cs.lti.ark.fn.parsing.CreateAlphabet.java

public static void main(String[] args) throws IOException {
    FEFileName.feFilename = args[0];// w ww . ja  v  a  2s  .c  o  m
    FEFileName.tagFilename = args[1];
    FEFileName.eventFilename = args[2];
    FEFileName.alphafilename = args[3];
    FEFileName.spanfilename = args[4];
    boolean genAlpha = Boolean.parseBoolean(args[5]);
    FEFileName.KBestParse = Integer.parseInt(args[6]);
    FEFileName.KBestParseDirectory = args[7];

    if (genAlpha)
        System.out.println("Generating alphabet too...");

    final List<String> feLines = readLines(new File(FEFileName.feFilename), UTF_8);
    final List<String> tagLines = readLines(new File(FEFileName.tagFilename), UTF_8);
    run(genAlpha, tagLines, feLines);
}

From source file:me.ryandowling.TwitchTools.java

public static void main(String[] args) {
    loadSettings();/* www  . ja v a 2 s  . c om*/

    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            saveSettings();
        }
    });

    if (args.length == 0) {
        System.err.println("Invalid number of arguments specified!");
        System.exit(1);
    } else if (args.length >= 1 && args.length <= 4) {
        switch (args[0]) {
        case "Followers":
            if (args.length == 4) {
                new Followers(args[1], Integer.parseInt(args[2]), Boolean.parseBoolean(args[3])).run();
            } else {
                System.err.println("Invalid number of arguments specified!");
                System.exit(1);
            }
            break;
        case "MicrophoneStatus":
            if (args.length == 3) {
                final int delay = Integer.parseInt(args[1]);
                final boolean guiDisplay = Boolean.parseBoolean(args[2]);

                new MicrophoneStatus(delay, guiDisplay);
            } else {
                System.err.println("Invalid number of arguments specified!");
                System.err.println("Arguments are: [delay in ms for updates] [if the gui should show]!");
                System.err.println("For example: [100] [true]!");
                System.exit(1);
            }
            break;
        case "NowPlayingConverter":
            if (args.length == 2) {
                final int delay = Integer.parseInt(args[1]);
                new NowPlayingConverter(delay).run();
            } else {
                System.err.println("Invalid number of arguments specified!");
                System.err.println("Arguments are: [delay in ms for updates]!");
                System.err.println("For example: [100]!");
                System.exit(1);
            }
            break;
        case "MusicCreditsGenerator":
            if (args.length == 2) {
                final String type = args[1];

                if (type.equalsIgnoreCase("html") || type.equalsIgnoreCase("october")
                        || type.equalsIgnoreCase("markdown")) {
                    new MusicCreditsGenerator(type).run();
                } else {
                    System.err.println("Invalid type argument specified!");
                    System.err.println("Arguments are: [type of output to generate (html|markdown|october)]!");
                    System.err.println("For example: [html]!");
                    System.exit(1);
                }
            } else {
                System.err.println("Invalid number of arguments specified!");
                System.err.println("Arguments are: [delay in ms for updates]!");
                System.err.println("For example: [100]!");
                System.exit(1);
            }
            break;
        case "SteamGamesGenerator":
            if (args.length == 2) {
                final String type = args[1];

                if (type.equalsIgnoreCase("october")) {
                    new SteamGamesGenerator(type).run();
                } else {
                    System.err.println("Invalid type argument specified!");
                    System.err.println("Arguments are: [type of output to generate (october)]!");
                    System.err.println("For example: [october]!");
                    System.exit(1);
                }
            } else {
                System.err.println("Invalid number of arguments specified!");
                System.err.println("Arguments are: [delay in ms for updates]!");
                System.err.println("For example: [100]!");
                System.exit(1);
            }
            break;
        case "FoobarControls":
            if (args.length == 1) {
                new FoobarControls().run();
            } else {
                System.err.println("Invalid number of arguments specified!");
                System.err.println("There are no arguments to provide!");
                System.exit(1);
            }
            break;
        default:
            System.err.println("Invalid tool name specified!");
            System.exit(1);
        }
    }
}

From source file:com.microsoftopentechnologies.adinteractiveauth.Program.java

public static void main(String[] args) {
    // we expect the following arguments to be passed in:
    //  [1] a/d login URL
    //  [2] redirect URI
    //  [3] callback url to which the auth code needs to be sent
    //  [4] window title text
    //  [5] optional boolean indicating whether we should invoke System.exit once done
    if (args.length < 4) {
        return;// w w  w  . ja va  2  s  . c o  m
    }

    String url = args[0];
    String redirectUri = args[1];
    final String callbackUrl = args[2];
    String windowTitle = args[3];
    boolean shouldExit = (args.length > 4) && Boolean.parseBoolean(args[4]);

    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText(windowTitle);
    Browser browser = null;
    ADAuthCodeCallback authCodeCallback = new ADAuthCodeCallback(display, callbackUrl);

    shell.setLayout(new FillLayout());
    Monitor monitor = display.getPrimaryMonitor();
    Rectangle bounds = monitor.getBounds();
    Dimension size = new Dimension((int) (bounds.width * 0.25), (int) (bounds.height * 0.55));
    shell.setSize(size.width, size.height);
    shell.setLocation((bounds.width - size.width) / 2, (bounds.height - size.height) / 2);

    try {
        browser = new org.eclipse.swt.browser.Browser(shell, SWT.NONE);
    } catch (SWTError err) {
        authCodeCallback.onFailed(
                "Unable to load the browser component on this system. Here's some additional information: \n"
                        + err.getMessage());
        return;
    }

    BrowserLocationListener locationListener = new BrowserLocationListener(redirectUri, authCodeCallback);
    browser.addLocationListener(locationListener);
    browser.setUrl(url);

    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }

    display.dispose();

    // notify the caller that the window was closed
    try {
        httpRequest(new URI(callbackUrl).resolve("closed").toURL());
    } catch (IOException ignored) {
    } catch (URISyntaxException ignored) {
    }

    if (shouldExit) {
        System.exit(0);
    }
}