List of usage examples for java.lang String equals
public boolean equals(Object anObject)
From source file:org.huahinframework.emanager.Runner.java
/** * @param args/*from w w w.j av a 2 s . c o m*/ */ public static void main(String[] args) { if (args.length != 4) { System.err.println("argument error: [start | stop] [war path] [port] [shutdown port]"); System.exit(-1); } String operation = args[0]; String war = args[1]; int port = Integer.valueOf(args[2]); int shutDownPort = Integer.valueOf(args[3]); Runner runner = new Runner(); if (operation.equals(OPERATION_START)) { runner.start(war, port, shutDownPort); } else if (operation.equals(OPERATION_STOP)) { runner.stop(shutDownPort); } System.exit(0); }
From source file:com.qcloud.project.macaovehicle.util.MessageGetter.java
public static void main(String[] args) throws Exception { // StringBuilder stringBuilder = new StringBuilder(); // stringBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><auditData><url>vehicle</url><success>0</success><vehicle><ric>1000001</ric><reason></reason><state>1</state></vehicle></auditData>"); // System.out.println(stringBuilder.toString()); // String dataPostURL = "http://120.25.12.206:8888/DeclMsg/Ciq"; // MessageGetter.sendXml(stringBuilder.toString(), dataPostURL); Map<String, Object> param = new LinkedHashMap<String, Object>(); param.put("driverIc", "C09000000002a6d32701"); param.put("driverName", ""); param.put("sex", "1"); param.put("birthday", "1991-09-01T00:00:00"); param.put("nationality", ""); param.put("corpName", "??"); param.put("registerNo", "C0900000000347736701"); param.put("drivingValidityDate", "2017-04-17T09:00:00"); param.put("commonFlag", "1"); param.put("residentcardValidityDate", "2014-04-27T09:00:00"); param.put("leftHandFingerprint", "1"); param.put("rightHandFingerprint", "2"); param.put("imageEignvalues", "3"); param.put("certificateNo", "4"); param.put("validityEndDate", "2020-04-17T09:00:00"); param.put("creator", ""); param.put("createDate", "2014-04-17T09:00:00"); param.put("modifier", ""); param.put("modifyDate", "2014-04-17T09:00:00"); param.put("cityCode", ""); param.put("nation", "?"); param.put("tel", "13568877897"); param.put("visaCode", "21212121"); param.put("subscriberCode", "7937"); param.put("visaValidityDate", "2017-04-17T09:00:00"); param.put("icCode", "TDriver000018950"); param.put("toCountry", ""); param.put("fromCountry", ""); param.put("licenseCode", "168819"); param.put("idCard", "440882199110254657"); param.put("secondName", ""); param.put("secondBirthday", "1991-04-17T09:00:00"); param.put("secondCertificateNo", "123456789"); param.put("secondCertificateType", "03"); param.put("visaNo", "123456789"); param.put("stayPeriod", "180"); param.put("residentcardValidityDate", "2017-04-27T09:00:00"); param.put("returnCardNo", "123456789"); param.put("pass", "123456789"); param.put("drivingLicense", "422801197507232815"); param.put("customCode", "12345"); param.put("visaCity", "?"); param.put("certificateType", "01"); param.put("certificateCode", "12345678"); param.put("subscribeDate", "2010-04-17T09:00:00"); param.put("passportNo", "G20961897"); param.put("transactType", "01"); param.put("isAvoidInspect", "N"); param.put("isPriorityInspect", "N"); param.put("remark", ""); String picSourcePath1 = "H://images/?.jpg"; // String picSourcePath1="H://images/1/1.jpg"; String picSourcePath2 = "H://images/1/2.jpeg"; String picSourcePath3 = "H://images/1/3.jpeg"; String picSourcePath4 = "H://images/1/4.jpeg"; String picSourcePath5 = "H://images/1/5.jpeg"; String picSourcePath6 = "H://images/1/6.jpeg"; param.put("driverPhoto", Base64PicUtil.GetImageStr(picSourcePath1)); // param.put("imageA", Base64PicUtil.GetImageStr(picSourcePath2)); // param.put("imageB", Base64PicUtil.GetImageStr(picSourcePath3)); // param.put("imageC", Base64PicUtil.GetImageStr(picSourcePath4)); // param.put("imageD", Base64PicUtil.GetImageStr(picSourcePath5)); String dataStr = MessageGetter.sendMessage(param, "driver", dataPostURL); Map<String, Object> map = XmlParseUtils.XmlToMap(dataStr); System.out.println(dataStr);/*from www .java 2s. c om*/ if (map.containsKey("message")) { String message = (String) map.get("message"); if (message.equals("true")) { System.out.println("==================================================="); System.out.println(map); } } System.out.println(dataStr); }
From source file:CommandLineInterpreter.java
/** * Main method, command line input will get parsed here. * * @param args//from w w w . j a v a 2s . co m */ public static void main(String[] args) { // // test-arguments: // args = new String[] { "1.9", "-gui" }; boolean success = false; if (args.length == 1) { String arg = args[0].trim().replaceAll("[-]+", ""); if (arg.equals("help") || arg.equals("h")) printHelp(null); } if (args.length == 0) { printHelp("ONE ARGUMENT NEEDED"); } else { try { boolean guiAlert = false; Float minVersion = null; File resourcesFile = null; // ------------------------------------------------ // // -- // ------------------------------------------------ // final String minJavaVersionArgument = args[0]; if (!minJavaVersionArgument.trim().isEmpty()) { try { minVersion = Float.parseFloat(minJavaVersionArgument); } catch (Exception e) { // do nothing } } if (minVersion == null || minVersion > 2 || minVersion < 1.6) { printHelp("VERSION STRING IS NOT VALID"); } // ------------------------------------------------ // // -- // ------------------------------------------------ // for (int i = 1; i < (args.length <= 3 ? args.length : 3); i++) { final String argument = args[i].trim(); if (argument.equals("-gui")) { guiAlert = true; } else { String resourcesFilePath = argument; if (!resourcesFilePath.isEmpty()) { resourcesFile = new File(resourcesFilePath); if (!resourcesFile.exists() || !resourcesFile.isFile() || !resourcesFile.canRead()) { printHelp("RESOURCES FILE IS NOT VALID\n[" + resourcesFile.getAbsolutePath() + "]"); } } } } // ------------------------------------------------ // // -- // ------------------------------------------------ // success = checkJREVersion(minVersion, guiAlert); if (success && resourcesFile != null) { success = checkResources(resourcesFile, guiAlert); } } catch (Exception e) { success = false; e.printStackTrace(); } } if (!success) { // set error exit code System.exit(1); } }
From source file:com.wordnik.swaggersocket.samples.NettoSphere.java
public static void main(String[] args) throws IOException { ReflectorServletProcessor rsp = new ReflectorServletProcessor(); rsp.setServletClassName(CXFNonSpringJaxrsServlet.class.getName()); int p = getHttpPort(); Config.Builder b = new Config.Builder(); b.resource("./app").initParam(ApplicationConfig.WEBSOCKET_CONTENT_TYPE, "application/json") .initParam(ApplicationConfig.WEBSOCKET_METHOD, "POST") .initParam("jaxrs.serviceClasses", SwaggerSocketResource.class.getName() + "," + FileServiceResource.class.getName()) .initParam("jaxrs.providers", JacksonJsonProvider.class.getName()) .initParam("com.wordnik.swaggersocket.protocol.lazywrite", "true") .initParam("com.wordnik.swaggersocket.protocol.emptyentity", "true") .interceptor(new SwaggerSocketProtocolInterceptor()).resource("/*", rsp).port(p).host("127.0.0.1") .build();/*from w ww . ja va 2s.c om*/ Nettosphere s = new Nettosphere.Builder().config(b.build()).build(); s.start(); String a = ""; logger.info("NettoSphere SwaggerSocket Server started on port {}", p); logger.info("Type quit to stop the server"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (!(a.equals("quit"))) { a = br.readLine(); } System.exit(-1); }
From source file:com.hurence.logisland.util.avro.eventgenerator.DataGenerator.java
public static void main(String[] args) throws IOException, UnknownTypeException { // load and verify the options CommandLineParser parser = new PosixParser(); Options opts = loadOptions();//from w ww . j av a2s . co m CommandLine cmd = null; try { cmd = parser.parse(opts, args); } catch (org.apache.commons.cli.ParseException parseEx) { logger.error("Invalid option"); printHelp(opts); return; } // check for necessary options String fileLoc = cmd.getOptionValue("schemaLocation"); if (fileLoc == null) { logger.error("schemaLocation not specified"); printHelp(opts); } //getField string length and check if min is greater than 0 // Generate the record File schemaFile = new File(fileLoc); DataGenerator dataGenerator = new DataGenerator(schemaFile); GenericRecord record = dataGenerator.generateRandomRecord(); if (cmd.hasOption(PRINT_AVRO_JSON_OPTNAME)) { String outname = cmd.getOptionValue(PRINT_AVRO_JSON_OPTNAME); OutputStream outs = System.out; if (!outname.equals("-")) { outs = new FileOutputStream(outname); } printAvroJson(record, outs); if (!outname.equals("-")) { outs.close(); } } else { DataGenerator.prettyPrint(record); } }
From source file:Main.java
public static void main(String[] args) { String input = "test"; Stack<Character> stack = new Stack<Character>(); for (int i = 0; i < input.length(); i++) { stack.push(input.charAt(i));/* ww w. j av a2 s .c om*/ } String reverseInput = ""; while (!stack.isEmpty()) { reverseInput += stack.pop(); } if (input.equals(reverseInput)) { System.out.println("Yo! that is a palindrome."); } else { System.out.println("No! that isn't a palindrome."); } }
From source file:eu.scape_project.tb.chutney.ChutneyDriver.java
/** * This main runs only on the local machine when the job is initiated * //from www . j a v a2s . c om * @param args command line arguments * @throws ParseException command line parse issue */ @SuppressWarnings("unused") public static void main(String[] args) throws ParseException { System.out.println(Settings.JOB_NAME + "v" + Settings.VERSION); //warning code if (true) { String yes = "YeS"; System.out.println( "WARNING: this code has not been fully tested and it may delete/modify/alter your systems"); System.out.println("You run this development code at your own risk, no liability is assumed"); System.out.print("To continue, type \"" + yes + "\": "); try { String input = new BufferedReader(new InputStreamReader(System.in)).readLine(); if (!input.equals(yes)) { return; } } catch (IOException e1) { return; } } //end of warning code try { ToolRunner.run(new Configuration(), new ChutneyDriver(), args); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.twentyn.bioreactor.pH.ControlSystem.java
public static void main(String[] args) throws Exception { Options opts = new Options(); for (Option.Builder b : OPTION_BUILDERS) { opts.addOption(b.build());//from ww w . ja va 2s . co m } CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { LOGGER.error(String.format("Argument parsing failed: %s\n", e.getMessage())); HELP_FORMATTER.printHelp(ControlSystem.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } if (cl.hasOption("help")) { HELP_FORMATTER.printHelp(ControlSystem.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); return; } SOLUTION solution = null; String acidOrBase = cl.getOptionValue(OPTION_CONTROL_SOLUTION); if (acidOrBase.equals(SOLUTION.ACID.name())) { solution = SOLUTION.ACID; } if (acidOrBase.equals(SOLUTION.BASE.name())) { solution = SOLUTION.BASE; } if (solution == null) { LOGGER.error("Input solution is neither %s or %s", SOLUTION.ACID.name(), SOLUTION.BASE.name()); return; } Double targetPH = Double.parseDouble(cl.getOptionValue(OPTION_TARGET_PH)); File sensorReadingDataFile = new File( cl.getOptionValue(OPTION_SENSOR_READING_FILE_LOCATION, SENSOR_READING_FILE_LOCATION)); MotorPinConfiguration motorPinConfiguration = new MotorPinConfiguration( MotorPinConfiguration.PinNumberingScheme.BOARD); motorPinConfiguration.initializeGPIOPinsAndSetConfigToStartState(); ControlSystem controlSystem = new ControlSystem(motorPinConfiguration, solution, targetPH, sensorReadingDataFile); controlSystem.registerModuleForObjectMapper(new JodaModule()); try { controlSystem.run(); } finally { LOGGER.info("Shutting down"); controlSystem.shutdownFermentation(); } }
From source file:com.cloud.test.longrun.PerformanceWithAPI.java
public static void main(String[] args) { List<String> argsList = Arrays.asList(args); Iterator<String> iter = argsList.iterator(); String host = "http://localhost"; int numThreads = 1; while (iter.hasNext()) { String arg = iter.next(); if (arg.equals("-h")) { host = "http://" + iter.next(); }/* w w w .j a v a 2 s . co m*/ if (arg.equals("-t")) { numThreads = Integer.parseInt(iter.next()); } if (arg.equals("-n")) { numVM = Integer.parseInt(iter.next()); } } final String server = host + ":" + _apiPort + "/"; final String developerServer = host + ":" + _developerPort + _apiUrl; s_logger.info("Starting test in " + numThreads + " thread(s). Each thread is launching " + numVM + " VMs"); for (int i = 0; i < numThreads; i++) { new Thread(new Runnable() { public void run() { try { String username = null; String singlePrivateIp = null; String singlePublicIp = null; Random ran = new Random(); username = Math.abs(ran.nextInt()) + "-user"; //Create User User myUser = new User(username, username, server, developerServer); try { myUser.launchUser(); myUser.registerUser(); } catch (Exception e) { s_logger.warn("Error code: ", e); } if (myUser.getUserId() != null) { s_logger.info("User " + myUser.getUserName() + " was created successfully, starting VM creation"); //create VMs for the user for (int i = 0; i < numVM; i++) { //Create a new VM, add it to the list of user's VMs VirtualMachine myVM = new VirtualMachine(myUser.getUserId()); myVM.deployVM(_zoneId, _serviceOfferingId, _templateId, myUser.getDeveloperServer(), myUser.getApiKey(), myUser.getSecretKey()); myUser.getVirtualMachines().add(myVM); singlePrivateIp = myVM.getPrivateIp(); if (singlePrivateIp != null) { s_logger.info( "VM with private Ip " + singlePrivateIp + " was successfully created"); } else { s_logger.info("Problems with VM creation for a user" + myUser.getUserName()); break; } //get public IP address for the User myUser.retrievePublicIp(_zoneId); singlePublicIp = myUser.getPublicIp().get(myUser.getPublicIp().size() - 1); if (singlePublicIp != null) { s_logger.info("Successfully got public Ip " + singlePublicIp + " for user " + myUser.getUserName()); } else { s_logger.info("Problems with getting public Ip address for user" + myUser.getUserName()); break; } //create ForwardProxy rules for user's VMs int responseCode = CreateForwardingRule(myUser, singlePrivateIp, singlePublicIp, "22", "22"); if (responseCode == 500) break; } s_logger.info("Deployment successful..." + numVM + " VMs were created. Waiting for 5 min before performance test"); Thread.sleep(300000L); // Wait //Start performance test for the user s_logger.info("Starting performance test for Guest network that has " + myUser.getPublicIp().size() + " public IP addresses"); for (int j = 0; j < myUser.getPublicIp().size(); j++) { s_logger.info("Starting test for user which has " + myUser.getVirtualMachines().size() + " vms. Public IP for the user is " + myUser.getPublicIp().get(j) + " , number of retries is " + _retry + " , private IP address of the machine is" + myUser.getVirtualMachines().get(j).getPrivateIp()); guestNetwork myNetwork = new guestNetwork(myUser.getPublicIp().get(j), _retry); myNetwork.setVirtualMachines(myUser.getVirtualMachines()); new Thread(myNetwork).start(); } } } catch (Exception e) { s_logger.error(e); } } }).start(); } }
From source file:movierecommend.MovieRecommend.java
public static void main(String[] args) throws ClassNotFoundException, SQLException { String url = "jdbc:sqlserver://localhost;databaseName=MovieDB;integratedSecurity=true"; Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); Connection conn = DriverManager.getConnection(url); Statement stm = conn.createStatement(); ResultSet rsRecnik = stm.executeQuery("SELECT Recnik FROM Recnik WHERE (ID_Zanra = 1)"); //citam recnik iz baze za odredjeni zanr String recnik[] = null;/*from w w w . jav a 2 s . c om*/ while (rsRecnik.next()) { recnik = rsRecnik.getString("Recnik").split(","); //delim recnik na reci } ResultSet rsFilmovi = stm.executeQuery( "SELECT TOP (200) Naziv_Filma, LemmaPlots, " + "ID_Filma FROM Film WHERE (ID_Zanra = 1)"); List<Film> listaFilmova = new ArrayList<>(); Film f = null; int rb = 0; while (rsFilmovi.next()) { f = new Film(rb, Integer.parseInt(rsFilmovi.getString("ID_Filma")), rsFilmovi.getString("Naziv_Filma"), rsFilmovi.getString("LemmaPlots")); listaFilmova.add(f); rb++; } //kreiranje vektorskog modela M = MatrixUtils.createRealMatrix(recnik.length, listaFilmova.size()); System.out.println("Prva tezinska matrica"); for (int i = 0; i < recnik.length; i++) { String recBaza = recnik[i]; for (Film film : listaFilmova) { for (String lemmaRec : film.getPlotLema()) { if (recBaza.equals(lemmaRec)) { M.setEntry(i, film.getRb(), M.getEntry(i, film.getRb()) + 1); } } } } //racunanje tf-idf System.out.println("td-idf"); M = LSA.calculateTfIdf(M); System.out.println("SVD"); //SVD SingularValueDecomposition svd = new SingularValueDecomposition(M); RealMatrix V = svd.getV(); RealMatrix Vk = V.getSubMatrix(0, V.getRowDimension() - 1, 0, brojDimenzija - 1); //dimenzija je poslednji argument //kosinusna slicnost System.out.println("Cosin simmilarity"); CallableStatement stmTop = conn.prepareCall("{call Dodaj_TopList(?,?,?)}"); for (int j = 0; j < listaFilmova.size(); j++) { Film fl = listaFilmova.get(j); List<Film> lFilmova1 = new ArrayList<>(); lFilmova1.add(listaFilmova.get(j)); double sim = 0.0; for (int k = 0; k < listaFilmova.size(); k++) { // System.out.println(listaFilmova.size()); sim = LSA.cosinSim(j, k, Vk.transpose()); listaFilmova.get(k).setSimilarity(sim); lFilmova1.add(listaFilmova.get(k)); } Collections.sort(lFilmova1); for (int k = 2; k < 13; k++) { stmTop.setString(1, fl.getID() + ""); stmTop.setString(2, lFilmova1.get(k).getID() + ""); stmTop.setString(3, lFilmova1.get(k).getSimilarity() + ""); stmTop.execute(); } } stm.close(); rsRecnik.close(); rsFilmovi.close(); conn.close(); }