List of usage examples for java.lang String String
public String(StringBuilder builder)
From source file:com.kotcrab.vis.editor.CrashReporter.java
public static void main(String[] args) throws IOException { if (args.length != 2) { System.out.println("Invalid args, exiting."); System.exit(0);/* w ww .j a va2 s.com*/ } restartCommand = args[0].replace("%", "\""); reportFile = new File(args[1]); if (reportFile.exists() == false) { System.out.println("Report file does not exist: " + args[1]); System.exit(0); } report = new String(Files.readAllBytes(reportFile.toPath())); launch(args); }
From source file:GetChannels.java
public static void main(String[] args) { System.out.println("Executing Get Channels"); try {/* w w w .j av a 2 s. co m*/ URL marketoSoapEndPoint = new URL("CHANGEME" + "?WSDL"); String marketoUserId = "CHANGEME"; String marketoSecretKey = "CHANGEME"; QName serviceName = new QName("http://www.marketo.com/mktows/", "MktMktowsApiService"); MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName); // Create Signature DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); String text = df.format(new Date()); String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22); String encryptString = requestTimestamp + marketoUserId; SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(secretKey); byte[] rawHmac = mac.doFinal(encryptString.getBytes()); char[] hexChars = Hex.encodeHex(rawHmac); String signature = new String(hexChars); // Set Authentication Header AuthenticationHeader header = new AuthenticationHeader(); header.setMktowsUserId(marketoUserId); header.setRequestTimestamp(requestTimestamp); header.setRequestSignature(signature); // Create Request ParamsGetChannels params = new ParamsGetChannels(); Tag tags = new Tag(); ArrayOfString tagArray = new ArrayOfString(); tagArray.getStringItems().add("Webinar"); tagArray.getStringItems().add("Blog"); tagArray.getStringItems().add("Tradeshow"); tags.setValues(tagArray); MktowsPort port = service.getMktowsApiSoapPort(); SuccessGetChannels result = port.getChannels(params, header); JAXBContext context = JAXBContext.newInstance(SuccessGetLead.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(result, System.out); } catch (Exception e) { e.printStackTrace(); } }
From source file:test.jackson.JacksonNsgiDiscover.java
public static void main(String[] args) throws IOException { ObjectMapper objectMapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT); String ngsiRcr = new String(Files.readAllBytes(Paths.get(NGSI_FILE))); DiscoveryContextAvailabilityRequest dcar = objectMapper.readValue(ngsiRcr, DiscoveryContextAvailabilityRequest.class); // System.out.println(objectMapper.writeValueAsString(dcar)); System.out.println(dcar.getRestriction().getOperationScope().get(1).getScopeValue()); LinkedHashMap shapeHMap = (LinkedHashMap) dcar.getRestriction().getOperationScope().get(1).getScopeValue(); // Association assocObject = objectMapper.convertValue(shapeHMap, Association.class); // System.out.println(assocObject.getAttributeAssociation().get(0).getSourceAttribute()); Shape shape = objectMapper.convertValue(shapeHMap, Shape.class); System.out.println("Deserialized Class: " + shape.getClass().getSimpleName()); System.out.println("VALUE: " + shape.getPolygon().getVertices().get(2).getLatitude()); System.out.println("VALUE: " + shape.getCircle()); if (!(shape.getCircle() == null)) System.out.println("This is null"); Polygon polygon = shape.getPolygon(); int vertexSize = polygon.getVertices().size(); Coordinate[] coords = new Coordinate[vertexSize]; final ArrayList<Coordinate> points = new ArrayList<>(); for (int i = 0; i < vertexSize; i++) { Vertex vertex = polygon.getVertices().get(i); points.add(new Coordinate(Double.valueOf(vertex.getLatitude()), Double.valueOf(vertex.getLongitude()))); coords[i] = new Coordinate(Double.valueOf(vertex.getLatitude()), Double.valueOf(vertex.getLongitude())); }//w w w. j a v a 2 s . co m points.add(new Coordinate(Double.valueOf(polygon.getVertices().get(0).getLatitude()), Double.valueOf(polygon.getVertices().get(0).getLongitude()))); final GeometryFactory gf = new GeometryFactory(); final Coordinate target = new Coordinate(49, -0.6); final Point point = gf.createPoint(target); Geometry shapeGm = gf.createPolygon( new LinearRing(new CoordinateArraySequence(points.toArray(new Coordinate[points.size()])), gf), null); // Geometry shapeGm = gf.createPolygon(coords); System.out.println(point.within(shapeGm)); // System.out.println(rcr.getContextRegistration().get(0).getContextMetadata().get(0).getValue().getClass().getCanonicalName()); // String assocJson = objectMapper.writeValueAsString(association); // Value assocObject = objectMapper.readValue(objectMapper.writeValueAsString(association), Value.class); // System.out.println(association.values().toString()); // System.out.println(assocJson); }
From source file:TwoStrings.java
public static void main(String[] argv) { String one = "A String"; String two = "A String"; String three = new String(one); compare(one, two);/*from w ww. ja v a 2 s .co m*/ compare(two, three); }
From source file:com.adobe.aem.demomachine.Base64Encoder.java
public static void main(String[] args) throws IOException { String value = null;/*from w w w . ja va 2 s. c o m*/ // Command line options for this tool Options options = new Options(); options.addOption("v", true, "Value"); CommandLineParser parser = new BasicParser(); try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("v")) { value = cmd.getOptionValue("v"); } if (value == null) { System.out.println("Command line parameters: -v value"); System.exit(-1); } } catch (ParseException ex) { logger.error(ex.getMessage()); } byte[] encodedBytes = Base64.encodeBase64(value.getBytes()); System.out.println(new String(encodedBytes)); }
From source file:bpgead2pdf.java
/** * Main method.//from w w w . j av a 2 s . co m * @param args command-line arguments */ public static void main(String[] args) { try { System.out.println("Preparing..."); // Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); // Setup input and output files File xmlfile = new File(args[0]); String xsltfile = new String("http://www.library.yale.edu/facc/xsl/fo/yul.ead2002.pdf.xsl"); String pdffn = new String(FilenameUtils.getBaseName(args[0]) + ".pdf"); File pdffile = new File(outDir, pdffn); System.out.println("Input: XML (" + xmlfile + ")"); System.out.println("Stylesheet: " + xsltfile); System.out.println("Output: PDF (" + pdffile + ")"); System.out.println(); System.out.println("Transforming..."); // configure fopFactory as desired FopFactory fopFactory = FopFactory.newInstance(); FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); // configure foUserAgent as desired // configure XSLT Processor Processor processor = new Processor(false); // Setup output OutputStream out = new java.io.FileOutputStream(pdffile); out = new java.io.BufferedOutputStream(out); try { // Construct fop with desired output format Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out); // Setup XSLT XsltCompiler compiler = processor.newXsltCompiler(); XsltExecutable transform = compiler.compile(new StreamSource(xsltfile)); XsltTransformer transformer = transform.load(); // Set the value of a <param> in the stylesheet // transformer.setParameter("versionParam", "2.0"); // Setup input for XSLT transformation Source src = new StreamSource(xmlfile); // Resulting SAX events (the generated FO) must be piped through to FOP SAXDestination res = new SAXDestination(fop.getDefaultHandler()); // Start XSLT transformation and FOP processing transformer.setDestination(res); transformer.setSource(src); transformer.transform(); } finally { out.close(); } System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); } }
From source file:com.yahoo.ads.pb.mttf.PistachiosMTTFTest.java
public static void main(String[] args) { PistachiosClient client;/* w w w. j ava 2s .co m*/ try { client = new PistachiosClient(); } catch (Exception e) { logger.info("error creating client", e); return; } Random rand = new Random(); while (true) { try { long id = rand.nextLong(); String value = InetAddress.getLocalHost().getHostName() + rand.nextInt(); client.store(0, id, value.getBytes()); for (int i = 0; i < 30; i++) { byte[] clientValue = client.lookup(0, id); String remoteValue = new String(clientValue); if (Arrays.equals(value.getBytes(), clientValue) || !remoteValue.contains(InetAddress.getLocalHost().getHostName())) { logger.debug("succeeded checking id {} value {}", id, value); } else { logger.error("failed checking id {} value {} != {}", id, value, new String(clientValue)); System.exit(0); } Thread.sleep(100); } } catch (Exception e) { System.out.println("error testing" + e); System.exit(0); } } }
From source file:StreamConverter.java
public static void main(String[] args) { String jaString = new String("\u65e5\u672c\u8a9e\u6587\u5b57\u5217"); writeOutput(jaString);/*from w w w .jav a2 s.co m*/ String inputString = readInput(); String displayString = jaString + " " + inputString; new ShowString(displayString, "Conversion Demo"); }
From source file:CollatorDemo.java
static public void main(String[] args) { testCompare();//ww w .j av a2s .c o m System.out.println(); Collator fr_FRCollator = Collator.getInstance(new Locale("fr", "FR")); Collator en_USCollator = Collator.getInstance(new Locale("en", "US")); String eWithCircumflex = new String("\u00EA"); String eWithAcute = new String("\u00E9"); String peachfr = "p" + eWithAcute + "ch" + eWithAcute; String sinfr = "p" + eWithCircumflex + "che"; String[] words = { peachfr, sinfr, "peach", "sin" }; sortStrings(fr_FRCollator, words); System.out.println("Locale: fr_FR"); printStrings(words); System.out.println(); sortStrings(en_USCollator, words); System.out.println("Locale: en_US"); printStrings(words); }
From source file:com.lexmark.saperion.util.ClientMultipartFormPost.java
public static void main(String[] args) throws Exception { String userName = "amolugu"; String password = "ecm"; String authString = userName + ":" + password; byte[] authEncBytes = Base64.encodeBase64(authString.getBytes()); String authStringEnc = new String(authEncBytes); CloseableHttpClient httpclient = HttpClients.createDefault(); try {//ww w .ja v a 2s . c o m HttpPost httpPost = new HttpPost("https://ecm-service.psft.co/ecms/documents"); //http httpPost.addHeader("Authorization", "Basic " + authStringEnc); httpPost.addHeader("Accept", "application/json"); httpPost.addHeader("saTenant", "india"); httpPost.addHeader("saLicense", "1"); httpPost.addHeader("Content-Type", "application/octet-stream"); FileBody bin = new FileBody(new File("C:\\Users\\Aditya.Molugu\\workspace\\RestClient\\Binaries.txt")); StringBody comment = new StringBody("A binary file of some kind", ContentType.TEXT_PLAIN); HttpEntity reqEntity = MultipartEntityBuilder.create().addPart("bin", bin).addPart("comment", comment) .build(); //HttpBo httpPost.setEntity(reqEntity); System.out.println("executing request " + httpPost.getRequestLine()); CloseableHttpResponse response = httpclient.execute(httpPost); try { System.out.println("----------------------------------------"); System.out.println(response.getStatusLine()); HttpEntity resEntity = response.getEntity(); if (resEntity != null) { System.out.println("Response content length: " + resEntity.getContentLength()); } EntityUtils.consume(resEntity); } finally { response.close(); } } finally { httpclient.close(); } }