List of usage examples for java.lang String equals
public boolean equals(Object anObject)
From source file:Main.java
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Username: "); String username = scanner.nextLine(); System.out.print("Password: "); String password = scanner.nextLine(); System.out.print("What is 2 + 2: "); int result = scanner.nextInt(); if (username.equals("admin") && password.equals("secret") && result == 4) { System.out.println("Welcome"); } else {//from w ww.j a va 2 s. c o m System.out.println("Invalid username or password!"); } }
From source file:com.liferay.mobile.sdk.BuilderAntTask.java
public static void main(String[] args) { Map<String, String> arguments = parseArguments(args); String url = arguments.get("url"); String context = arguments.get("context"); String filter = arguments.get("filter"); StringBuilder sb = new StringBuilder(); sb.append(url);/* w w w . j a va 2 s . co m*/ if (Validator.isNotNull(context)) { sb.append("/"); sb.append(context); } sb.append("/api/jsonws?discover"); if (Validator.isNull(filter)) { sb.append("=/*"); } else { sb.append("=/"); sb.append(filter); sb.append("/*"); } HttpClient client = new DefaultHttpClient(); HttpGet get = new HttpGet(sb.toString()); DiscoveryResponseHandler handler = new DiscoveryResponseHandler(); try { String builderType = arguments.get("builder"); Builder builder = null; if (builderType.equals("android")) { builder = new AndroidBuilder(); } Discovery discovery = client.execute(get, handler); PortalVersion version = HttpUtil.getPortalVersion(url); if (Validator.isNull(filter)) { builder.buildAll(version, discovery); } else { builder.build(filter, version, discovery); } } catch (Exception e) { e.printStackTrace(); } }
From source file:eu.scape_project.pc.hadoop.TikaIdentifyHadoopJob.java
/** * The main entry point./*from w ww. j a va 2 s.c o m*/ */ public static void main(String[] args) throws ParseException { Configuration conf = new Configuration(); GenericOptionsParser gop = new GenericOptionsParser(conf, args); HadoopJobCliConfig pc = new HadoopJobCliConfig(); CommandLineParser cmdParser = new PosixParser(); CommandLine cmd = cmdParser.parse(HadoopJobOptions.OPTIONS, gop.getRemainingArgs()); if ((args.length == 0) || (cmd.hasOption(HadoopJobOptions.HELP_OPT))) { HadoopJobOptions.exit("Usage", 0); } else { HadoopJobOptions.initOptions(cmd, pc); } String dir = pc.getDirStr(); String name = pc.getHadoopJobName(); if (name == null || name.equals("")) { name = "tika_identification"; } try { Job job = new Job(conf, name); // local debugging // job.getConfiguration().set("mapred.job.tracker", "local"); // job.getConfiguration().set("fs.default.name", "file:///"); job.setJarByClass(TikaIdentifyHadoopJob.class); job.setMapperClass(TikaIdentifyMapper.class); //job.setCombinerClass(TikaIdentifyReducer.class); job.setReducerClass(TikaIdentifyReducer.class); job.setInputFormatClass(TextInputFormat.class); job.setOutputFormatClass(TextOutputFormat.class); //SequenceFileOutputFormat.setOutputCompressionType(job, SequenceFile.CompressionType.NONE); //conf.setMapOutputKeyClass(Text.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(LongWritable.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(LongWritable.class); SequenceFileInputFormat.addInputPath(job, new Path(dir)); String outpath = "output/" + System.currentTimeMillis() + "tid"; FileOutputFormat.setOutputPath(job, new Path(outpath)); job.waitForCompletion(true); System.out.print(outpath); System.exit(0); } catch (Exception e) { logger.error("I/O error", e); } }
From source file:com.home.ln_spring.ch4.NonSingleton.java
public static void main(String[] args) { GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ctx.load("classpath:app-context-xml.xml"); ctx.refresh();//from w w w . ja v a2 s . c o m String str1 = (String) ctx.getBean("nonSingleton"); String str2 = (String) ctx.getBean("nonSingleton"); System.out.println("Identity Equal?: " + (str1 == str2)); System.out.println("Value Equal:? " + str1.equals(str2)); System.out.println(str1); System.out.println(str2); }
From source file:FactQuoter.java
public static void main(String[] args) throws IOException { // This is how we set things up to read lines of text from the user. BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); // Loop forever for (;;) {//from w w w . j a va 2 s. c o m // Display a prompt to the user System.out.print("FactQuoter> "); // Read a line from the user String line = in.readLine(); // If we reach the end-of-file, // or if the user types "quit", then quit if ((line == null) || line.equals("quit")) break; // Try to parse the line, and compute and print the factorial try { int x = Integer.parseInt(line); System.out.println(x + "! = " + Factorial4.factorial(x)); } // If anything goes wrong, display a generic error message catch (Exception e) { System.out.println("Invalid Input"); } } }
From source file:org.switchyard.quickstarts.demo.policy.security.wss.signencrypt.WorkServiceMain.java
public static void main(String... args) throws Exception { Set<String> policies = new HashSet<String>(); for (String arg : args) { arg = Strings.trimToNull(arg);//from ww w. j a v a2 s . c o m if (arg != null) { if (arg.equals(CONFIDENTIALITY) || arg.equals(SIGNENCRYPT) || arg.equals(HELP)) { policies.add(arg); } else { LOGGER.error(MAVEN_USAGE); throw new Exception(MAVEN_USAGE); } } } if (policies.contains(HELP)) { LOGGER.info(MAVEN_USAGE); } else { final String scheme; final int port; if (policies.contains(CONFIDENTIALITY)) { scheme = "https"; port = getPort(8443); SSLContext sslcontext = SSLContext.getInstance("TLS"); sslcontext.init(null, null, null); SSLSocketFactory sf = new SSLSocketFactory(sslcontext, SSLSocketFactory.STRICT_HOSTNAME_VERIFIER); Scheme https = new Scheme(scheme, port, sf); SchemeRegistry sr = new SchemeRegistry(); sr.register(https); } else { scheme = "http"; port = getPort(8080); } boolean signencrypt = policies.contains(SIGNENCRYPT); invokeWorkService(scheme, port, getContext(), signencrypt); } }
From source file:eu.scape_project.pc.hadoop.DroidIdentifyHadoopJob.java
/** * The main entry point./*from w ww .j av a 2 s . c o m*/ */ public static void main(String[] args) throws ParseException { Configuration conf = new Configuration(); GenericOptionsParser gop = new GenericOptionsParser(conf, args); HadoopJobCliConfig pc = new HadoopJobCliConfig(); CommandLineParser cmdParser = new PosixParser(); CommandLine cmd = cmdParser.parse(HadoopJobOptions.OPTIONS, gop.getRemainingArgs()); if ((args.length == 0) || (cmd.hasOption(HadoopJobOptions.HELP_OPT))) { HadoopJobOptions.exit("Usage", 0); } else { HadoopJobOptions.initOptions(cmd, pc); } String dir = pc.getDirStr(); String name = pc.getHadoopJobName(); if (name == null || name.equals("")) { name = "droid_identification"; } try { Job job = new Job(conf, name); // local debugging // job.getConfiguration().set("mapred.job.tracker", "local"); // job.getConfiguration().set("fs.default.name", "file:///"); job.setJarByClass(DroidIdentifyHadoopJob.class); job.setMapperClass(DroidIdentifyMapper.class); //job.setCombinerClass(DroidIdentifyReducer.class); job.setReducerClass(DroidIdentifyReducer.class); job.setInputFormatClass(TextInputFormat.class); job.setOutputFormatClass(TextOutputFormat.class); //SequenceFileOutputFormat.setOutputCompressionType(job, SequenceFile.CompressionType.NONE); //conf.setMapOutputKeyClass(Text.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(LongWritable.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(LongWritable.class); SequenceFileInputFormat.addInputPath(job, new Path(dir)); String outpath = "output/" + System.currentTimeMillis() + "dri"; FileOutputFormat.setOutputPath(job, new Path(outpath)); job.waitForCompletion(true); System.out.print(outpath); System.exit(0); } catch (Exception e) { logger.error("I/O error", e); } }
From source file:com.cilogi.lid.util.TEA.java
public static void main(String[] args) { /* Create a cipher using the first 16 bytes of the passphrase */ TEA tea = new TEA("And is there honey still for tea?".getBytes()); byte[] original = quote.getBytes(Charsets.UTF_8); /* Run it through the cipher... and back */ byte[] crypt = tea.encrypt(original); byte[] result = tea.decrypt(crypt); /* Ensure that all went well */ String test = new String(result, Charsets.UTF_8); if (!test.equals(quote)) throw new RuntimeException("Fail"); }
From source file:cat.tv3.eng.rec.recomana.lupa.visualization.ClustersToJson.java
public static void main(String[] args) throws IOException { String host = args[0];// www . j a va 2s . co m int port = Integer.parseInt(args[1]); Jedis jedis = new Jedis(host, port, 20000); // Cluster to binary tree visualitzation Map<String, String> attr_cluster = jedis.hgetAll("ClusterBinaryTree-Arrel"); String cluster_name = attr_cluster.get("cluster_ids_name"); JSONObject cluster; if (!cluster_name.equals("cluster_splited")) { cluster = new JSONObject(); cluster.put("name", "arrel"); } else { String id_left_centroid = attr_cluster.get("id_left_centroid"); String id_right_centroid = attr_cluster.get("id_right_centroid"); String hash_left = attr_cluster.get("hash_left"); String hash_right = attr_cluster.get("hash_right"); cluster = new JSONObject(); cluster.put("name", "arrel"); cluster.put("children", hashToJSONArrayRepresentationBinaryTree(id_left_centroid, hash_left, jedis, id_right_centroid, hash_right)); } jedis.disconnect(); Writer out = new BufferedWriter( new OutputStreamWriter(new FileOutputStream("data_toVisualize/cluster.json"), "UTF-8")); try { out.write(cluster.toJSONString()); } finally { out.close(); } }
From source file:org.switchyard.quickstarts.demo.security.propagation.jms.WorkServiceMain.java
public static void main(String... args) throws Exception { Set<String> policies = new HashSet<String>(); for (String arg : args) { arg = Strings.trimToNull(arg);//from ww w . j a v a 2s . c o m if (arg != null) { if (arg.equals(CONFIDENTIALITY) || arg.equals(CLIENT_AUTHENTICATION) || arg.equals(HELP)) { policies.add(arg); } else { LOGGER.error(MAVEN_USAGE); throw new Exception(MAVEN_USAGE); } } } if (policies.contains(HELP)) { LOGGER.info(MAVEN_USAGE); } else { final String scheme; final int port; if (policies.contains(CONFIDENTIALITY)) { scheme = "https"; port = getPort(8443); SSLContext sslcontext = SSLContext.getInstance("TLS"); sslcontext.init(null, null, null); SSLSocketFactory sf = new SSLSocketFactory(sslcontext, SSLSocketFactory.STRICT_HOSTNAME_VERIFIER); Scheme https = new Scheme(scheme, port, sf); SchemeRegistry sr = new SchemeRegistry(); sr.register(https); } else { scheme = "http"; port = getPort(8080); } String[] userPass = policies.contains(CLIENT_AUTHENTICATION) ? new String[] { "kermit", "the-frog-1" } : null; invokeWorkService(scheme, port, getContext(), userPass); } }