List of usage examples for java.lang Integer toString
public String toString()
From source file:Main.java
public static void main(String[] args) { Integer intObj = new Integer(10); String str = intObj.toString(); System.out.println("Integer converted to String as " + str); }
From source file:Main.java
public static void main(String[] args) { Integer intObject = new Integer(999); System.out.println(intObject.toString()); }
From source file:Main.java
public static void main(String[] args) { Integer num = 12345; Integer[] digits = getDigits(num.toString()); System.out.println(Arrays.toString(digits)); }
From source file:Main.java
public static void main(String[] args) { Rectangle r = new Rectangle(100, 325); Class c = r.getClass();/* w w w. j a v a 2 s . com*/ try { Field heightField = c.getField("height"); heightField.setInt(r, 1000); Integer heightValue = (Integer) heightField.get(r); System.out.println("Height: " + heightValue.toString()); } catch (Exception e) { System.out.println(e); } }
From source file:edu.berkeley.compbio.ncbitaxonomy.Exporter.java
public static void main(String[] argv) { try {//from w w w. j av a2 s . co m ApplicationContext ctx = NcbiTaxonomyDbContextFactory.makeNcbiTaxonomyDbContext(); NcbiTaxonomyPhylogeny ncbi = (NcbiTaxonomyPhylogeny) ctx.getBean("ncbiTaxonomyPhylogeny"); FileWriter treeWriter = new FileWriter("tree.newick"); ncbi.toNewick(treeWriter, "", "", 0, 0); treeWriter.close(); FileWriter synonymWriter = new FileWriter("synonyms"); ncbi.writeSynonyms(synonymWriter); synonymWriter.close(); for (String rank : ranks) { FileWriter rankWriter = new FileWriter(rank); Set<Integer> ids = ncbi.getTaxIdsWithRank(rank); for (Integer id : ids) { rankWriter.append(id.toString()).append("\n"); } rankWriter.close(); } } catch (Throwable e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { Rectangle r = new Rectangle(100, 325); Class c = r.getClass();/*from w ww.j a v a2 s. c o m*/ try { Field heightField = c.getField("height"); Integer heightValue = (Integer) heightField.get(r); System.out.println("Height: " + heightValue.toString()); } catch (NoSuchFieldException e) { System.out.println(e); } catch (SecurityException e) { System.out.println(e); } catch (IllegalAccessException e) { System.out.println(e); } }
From source file:Main.java
public static void main(String[] args) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); String oeStartDateStr = "04/01/2015"; String oeEndDateStr = "11/14/2015"; Calendar cal = Calendar.getInstance(); Integer year = cal.get(Calendar.YEAR); oeStartDateStr = oeStartDateStr.concat(year.toString()); oeEndDateStr = oeEndDateStr.concat(year.toString()); Date startDate = sdf.parse(oeStartDateStr); Date endDate = sdf.parse(oeEndDateStr); Date d = new Date(); String currDt = sdf.format(d); if ((d.after(startDate) && (d.before(endDate))) || (currDt.equals(sdf.format(startDate)) || currDt.equals(sdf.format(endDate)))) { System.out.println("Date is between 1st april to 14th nov..."); } else {/*from w ww . j av a 2s . c o m*/ System.out.println("Date is not between 1st april to 14th nov..."); } }
From source file:com.bdx.rainbow.service.jc.impl.DrugService.java
public static final void main(String[] arg) throws Exception { // String json = "{" // +"\"info\": {" // +"\"expired\": false, " // +"\"license_number\": \"?Z11020356\"," // +"\"thumb_url\": \"\", " // +"\"last_time\": \"20150402\", " // +"\"flow\": \"????,\", " // +"\"pkg_spec\": \"10\", " // +"\"sale_time\": \"\", " // +"\"title\": \"??\", " // +"\"prepn_type\": \"\", " // +"\"query_time\": 15, " // +"\"prepn_unit\": \"\", " // +"\"pkg_unit\": \"\", " // +"\"issue_expiry\": \"20150811\", " // +"\"first_query\": \"20151106 094927\", " // +"\"is_sale\": false, " // +"\"retcode\": 0, " // +"\"last_ent\": \"??\", " // +"\"production_batch\": 13112522, " // +"\"status\": \"???????\", " // +"\"sale_ent\": \"\", " // +"\"code\": 8.120280038460442E19, " // +"\"production_date\": \"20130515\", " // +"\"specifications\": \"?5g\", " // +"\"category\": \"??\", " // +"\"manufacturer\": \"??????\", " // +"\"expiry_date\": \"20160430\"" // +"}" // +"}"; // /*from w w w . j ava2 s. c om*/ // ObjectMapper mapper = new ObjectMapper(); // Map map = (Map)mapper.readValue(json, Map.class); // Map infoMap = (Map)map.get("info"); // // // Drc drc = new Drc(); // drc.setCategory((String)infoMap.get("license_number")); // drc.setLastTime((String)infoMap.get("last_time")); // drc.setFlow((String)infoMap.get("flow")); // drc.setPkgSpec((String)infoMap.get("pkg_spec")); // drc.setSaleTime((String)infoMap.get("sale_time")); // drc.setTitle((String)infoMap.get("title")); // drc.setPrepnType((String)infoMap.get("prepn_type")); // drc.setPrepnUnit((String)infoMap.get("prepn_unit")); // drc.setPkgUnit((String)infoMap.get("pkg_unit")); // drc.setIssueExpiry((String)infoMap.get("issue_expiry")); // drc.setFirstQuery((String)infoMap.get("first_query")); // drc.setLastEnt((String)infoMap.get("last_ent")); // drc.setProductionBatch((Integer)infoMap.get("production_batch")+""); //// drc.setSt((String)infoMap.get("status")); //// drc.set((String)infoMap.get("sale_ent")); // drc.setJgmCode((Double)infoMap.get("code")+""); // drc.setProductionBatch((String)infoMap.get("production_date")); // drc.setSpecifications((String)infoMap.get("specifications")); // drc.setCategory((String)infoMap.get("category")); // drc.setManufacturer((String)infoMap.get("manufacturer")); // drc.setExpiryDate((String)infoMap.get("expiry_date")); // //// 81202800384604426739 // BigDecimal v = new BigDecimal((Double)infoMap.get("code")); // // System.out.println(v.toBigInteger()); Integer i = new Integer(0); System.out.println(i.toString()); // System.out.println(mapper.writeValueAsString(drc)); }
From source file:cf.service.TestBroker.java
public static void main(String[] args) throws Exception { final CfTokens cfTokens = new CfTokens(); final CfTokens.CfToken target = cfTokens.getCurrentTargetToken(); if (target == null) { System.err.println("It appears you haven't logged into a Cloud Foundry instance with cf."); return;// w w w. ja v a 2 s. c o m } if (target.getVersion() == null || target.getVersion() != 2) { System.err.println("You must target a v2 Cloud Controller using cf."); return; } if (target.getSpaceGuid() == null) { System.err.println("You must select a space to use using cf."); return; } LOGGER.info("Using Cloud Controller at: {}", target.getTarget()); final int serverPort = 8000; final String label = "testbroker"; final String provider = "Tester"; final String url = "http://" + localIp(target.getTarget()) + ":" + serverPort; final String description = "A service used for testing the service framework."; final String version = "0.1"; final String servicePlan = "ServicePlan"; final String servicePlanDescription = "Finest service... ever."; final String authToken = "SsshhhThisIsASecret"; final CloudController cloudController = new DefaultCloudController(new DefaultHttpClient(), target.getTarget()); final UUID serviceGuid = UUID.randomUUID(); // We need to keep track of the services GUID. // final String serviceGuid = cloudControllerClient.createService(new CreateServiceRequest( // label, provider, url, description, version // )); // LOGGER.debug("Created service with guid: {}", serviceGuid); // try (final SimpleHttpServer server = new SimpleHttpServer(new InetSocketAddress(serverPort))) { new NettyBrokerServer(server, new Provisioner() { private final AtomicInteger id = new AtomicInteger(); @Override public ServiceInstance create(CreateRequest request) { LOGGER.info("Creating service"); final Integer i = id.getAndIncrement(); final ServiceInstance serviceInstance = new ServiceInstance(i.toString()); serviceInstance.addGatewayDataField("key", "value"); serviceInstance.addCredential("user", "test"); return serviceInstance; } @Override public void delete(String instanceId) { } @Override public ServiceBinding bind(BindRequest request) { LOGGER.info("Binding service"); final Integer i = id.getAndIncrement(); final ServiceBinding serviceBinding = new ServiceBinding(request.getServiceInstanceId(), i.toString()); serviceBinding.addGatewayDataField("bindkey", "bind value"); serviceBinding.addCredential("binduser", "test"); return serviceBinding; } @Override public void unbind(String instanceId, String handleId) { } @Override public Iterable<String> serviceInstanceIds() { return null; } @Override public Iterable<String> bindingIds(String instanceId) { return null; } @Override public void removeOrphanedBinding(String instanceId, String bindingId) { } @Override public void removeOrphanedServiceInstance(String instanceId) { } }, authToken); // final String serviceGuid = cloudControllerClient.createService(new CreateServiceRequest( // label, provider, url, description, version // )); // LOGGER.debug("Created service with guid: {}", serviceGuid); // // final String servicePlanGuid = cloudControllerClient.createServicePlan(new CreateServicePlanRequest(servicePlan, servicePlanDescription, serviceGuid)); // LOGGER.debug("Created service plan with guid: {}", serviceGuid); // // final String authTokenGuid = cloudControllerClient.createAuthToken(new CreateAuthTokenRequest(label, provider, authToken)); // LOGGER.debug("Created service token with guid: {}", authTokenGuid); // // final String instanceName = "testservice"; // final String serviceInstaceGuid = cloudControllerClient.createServiceInstance(instanceName, servicePlanGuid, target.getSpaceGuid()); System.in.read(); } }
From source file:de.tudarmstadt.ukp.experiments.dip.wp1.documents.Step2FillWithRetrievedResults.java
public static void main(String[] args) throws IOException { // input dir - list of xml query containers File inputDir = new File(args[0]); // retrieved results from Technion // ltr-50queries-100docs.txt File ltr = new File(args[1]); // output dir File outputDir = new File(args[2]); if (!outputDir.exists()) { outputDir.mkdirs();//from ww w . j av a2 s .c om } // load the query containers first (into map: id + container) Map<String, QueryResultContainer> queryResults = new HashMap<>(); for (File f : FileUtils.listFiles(inputDir, new String[] { "xml" }, false)) { System.out.println(f); QueryResultContainer queryResultContainer = QueryResultContainer .fromXML(FileUtils.readFileToString(f, "utf-8")); queryResults.put(queryResultContainer.qID, queryResultContainer); } // iterate over IR results for (String line : FileUtils.readLines(ltr)) { String[] split = line.split("\\s+"); Integer origQueryId = Integer.valueOf(split[0]); String clueWebID = split[2]; Integer rank = Integer.valueOf(split[3]); double score = Double.valueOf(split[4]); String additionalInfo = split[5]; // get the container for this result QueryResultContainer container = queryResults.get(origQueryId.toString()); if (container != null) { // add new result QueryResultContainer.SingleRankedResult result = new QueryResultContainer.SingleRankedResult(); result.clueWebID = clueWebID; result.rank = rank; result.score = score; result.additionalInfo = additionalInfo; if (container.rankedResults == null) { container.rankedResults = new ArrayList<>(); } container.rankedResults.add(result); } } // save all containers to the output dir for (QueryResultContainer queryResultContainer : queryResults.values()) { File outputFile = new File(outputDir, queryResultContainer.qID + ".xml"); FileUtils.writeStringToFile(outputFile, queryResultContainer.toXML(), "utf-8"); System.out.println("Finished " + outputFile); } }