List of usage examples for java.lang String trim
public String trim()
From source file:MainClass.java
public static void main(String args[]) { String org = "This is a test. This is, too. "; System.out.println(">" + org + "<"); System.out.println(">" + org.trim() + "<"); }
From source file:org.fusesource.cloudmix.tests.consumer.Main.java
public static void main(String[] args) { if (args.length > 0 && args[0].equals("-debug")) { Map<Object, Object> properties = new TreeMap<Object, Object>(); properties.putAll(System.getProperties()); for (Map.Entry<Object, Object> entry : properties.entrySet()) { System.out.println(" " + entry.getKey() + " = " + entry.getValue()); }// w ww . j av a2 s.c om } ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext( "META-INF/spring/context.xml"); applicationContext.start(); System.out.println("Enter quit to stop"); try { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); while (true) { String line = reader.readLine(); if (line == null || line.trim().equalsIgnoreCase("quit")) { break; } } } catch (IOException e) { System.err.println("Caught: " + e); e.printStackTrace(System.err); } applicationContext.close(); }
From source file:org.fusesource.cloudmix.tests.broker.Main.java
public static void main(String[] args) { if (verbose || (args.length > 0 && args[0].equals("-debug"))) { Map<Object, Object> properties = new TreeMap<Object, Object>(); properties.putAll(System.getProperties()); for (Map.Entry<Object, Object> entry : properties.entrySet()) { System.out.println(" " + entry.getKey() + " = " + entry.getValue()); }//from ww w . j av a 2s . c o m } ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext( "META-INF/spring/activemq.xml"); applicationContext.start(); System.out.println("Enter quit to stop"); try { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); while (true) { String line = reader.readLine(); if (line == null || line.trim().equalsIgnoreCase("quit")) { break; } } } catch (IOException e) { System.err.println("Caught: " + e); e.printStackTrace(System.err); } applicationContext.close(); }
From source file:com.ok2c.lightmtp.examples.SendMailExample.java
public static void main(final String[] args) throws Exception { if (args.length < 3) { System.out.println("Usage: sender recipient1[;recipient2;recipient3;...] file"); System.exit(0);/*from w ww. j a v a2 s . c om*/ } String sender = args[0]; List<String> recipients = new ArrayList<String>(); StringTokenizer tokenizer = new StringTokenizer(args[1], ";"); while (tokenizer.hasMoreTokens()) { String s = tokenizer.nextToken(); s = s.trim(); if (s.length() > 0) { recipients.add(s); } } File src = new File(args[2]); if (!src.exists()) { System.out.println("File '" + src + "' does not exist"); System.exit(0); } DeliveryRequest request = new BasicDeliveryRequest(sender, recipients, new FileSource(src)); MailUserAgent mua = new DefaultMailUserAgent(TransportType.SMTP, IOReactorConfig.DEFAULT); mua.start(); try { InetSocketAddress address = new InetSocketAddress("localhost", 2525); Future<DeliveryResult> future = mua.deliver(new SessionEndpoint(address), 0, request, null); DeliveryResult result = future.get(); System.out.println("Delivery result: " + result); } finally { mua.shutdown(); } }
From source file:DualModal.java
public static void main(String args[]) { final JFrame frame1 = new JFrame("Left"); final JFrame frame2 = new JFrame("Right"); frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button1 = new JButton("Left"); JButton button2 = new JButton("Right"); frame1.add(button1);/*from www . java 2 s . c om*/ frame2.add(button2); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { JButton source = (JButton) e.getSource(); JOptionPane pane = new JOptionPane("New label", JOptionPane.QUESTION_MESSAGE); pane.setWantsInput(true); JDialog dialog = pane.createDialog(frame2, "Enter Text"); // dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); dialog.setModalityType(Dialog.ModalityType.DOCUMENT_MODAL); dialog.setVisible(true); String text = (String) pane.getInputValue(); if (!JOptionPane.UNINITIALIZED_VALUE.equals(text) && text.trim().length() > 0) { source.setText(text); } } }; button1.addActionListener(listener); button2.addActionListener(listener); frame1.setBounds(100, 100, 200, 200); frame1.setVisible(true); frame2.setBounds(400, 100, 200, 200); frame2.setVisible(true); }
From source file:org.kuali.student.git.tools.Main.java
/** * @param args/*from ww w . jav a 2s.com*/ */ public static void main(String[] args) { if (args.length != 2) { log.error("USAGE: <path to git repository> <data file>"); System.exit(-1); } String pathToGitRepo = args[0]; String comparisonTagDataFile = args[1]; try { ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext( "git/applicationContext.xml"); applicationContext.registerShutdownHook(); GitExtractor extractor = applicationContext.getBean(GitExtractor.class); extractor.buildRepository(new File(pathToGitRepo)); List<String> pathsToCompare = FileUtils.readLines(new File(comparisonTagDataFile), "UTF-8"); for (String comparisonPath : pathsToCompare) { if (comparisonPath.trim().length() == 0 || comparisonPath.trim().startsWith("#")) continue; // skip empty lines and comments String parts[] = comparisonPath.split(":"); String targetTag = parts[0]; String copyFromTag = parts[1]; extractor.extractDifference(targetTag, copyFromTag); } } catch (Exception e) { log.error("Unexpected Exception", e); } }
From source file:org.springintegration.demo.Main.java
/** * Load the Spring Integration Application Context * * @param args - command line arguments/* ww w .jav a 2s .c om*/ */ public static void main(final String... args) { LOGGER.info("\n=========================================================" + "\n " + "\n Welcome to Spring Integration! " + "\n " + "\n For more information please visit: " + "\n http://www.springsource.org/spring-integration " + "\n " + "\n========================================================="); final AbstractApplicationContext context = new ClassPathXmlApplicationContext( "classpath:META-INF/spring/integration/*-context.xml"); context.registerShutdownHook(); final Scanner scanner = new Scanner(System.in); LOGGER.info("\n=========================================================" + "\n " + "\n Please press 'q + Enter' to quit the application. " + "\n " + "\n========================================================="); System.out.print("Please enter a string and press <enter>: "); while (true) { final String input = scanner.nextLine(); if ("q".equals(input.trim())) { break; } } LOGGER.info("Exiting application...bye."); System.exit(0); }
From source file:EchoServer.java
public static void main(String[] args) { try {//from ww w . ja va2 s .com // establish server socket ServerSocket s = new ServerSocket(8189); // wait for client connection Socket incoming = s.accept(); try { InputStream inStream = incoming.getInputStream(); OutputStream outStream = incoming.getOutputStream(); Scanner in = new Scanner(inStream); PrintWriter out = new PrintWriter(outStream, true /* autoFlush */); out.println("Hello! Enter BYE to exit."); // echo client input boolean done = false; while (!done && in.hasNextLine()) { String line = in.nextLine(); out.println("Echo: " + line); if (line.trim().equals("BYE")) done = true; } } finally { incoming.close(); } } catch (IOException e) { e.printStackTrace(); } }
From source file:mx.uaq.facturacion.enlace.system.EmailSystemTest.java
/** * Load the Spring Integration Application Context * * @param args//from w ww.j a v a 2s. c o m * - command line arguments */ public static void main(final String... args) { LOGGER.info(HORIZONTAL_LINE + "\n" + "\n Welcome to Spring Integration! " + "\n" + "\n For more information please visit: " + "\n http://www.springsource.org/spring-integration " + "\n" + HORIZONTAL_LINE); final AbstractApplicationContext context = new ClassPathXmlApplicationContext( "classpath:email-facturas.poller.xml", "classpath:facturacion-integration.xml"); context.registerShutdownHook(); final Scanner scanner = new Scanner(System.in); LOGGER.info(HORIZONTAL_LINE + "\n" + "\n Please press 'q + Enter' to quit the application. " + "\n" + HORIZONTAL_LINE); while (true) { final String input = scanner.nextLine(); if ("q".equals(input.trim())) { break; } } LOGGER.info("Exiting application...bye."); System.exit(0); }
From source file:net.semanticmetadata.lire.solr.SearchImages.java
public static void main(String[] args) throws IOException, ParserConfigurationException, SAXException { // http://localhost:8080/solr/lire/query?q=hashes%3A1152++hashes%3A605++hashes%3A96++hashes%3A275++&wt=xml String hashes = "1152 605 96 275 2057 3579 3950 2831 2367 3169 3292 974 2465 1573 2933 3125 314 2158 3532 974 2198 2315 3013 3302 3316 1467 2213 818 3 1083 18 2604 327 1370 593 3677 464 79 256 984 2496 1124 855 2091 780 1941 1887 1145 1396 4016 2406 2227 1532 2598 215 1375 171 2516 1698 368 2350 3799 223 1471 2083 1051 3015 3789 3374 1442 3991 3575 1452 751 428 3103 1182 2241 474 275 3678 3970 559 3394 2662 2361 2048 1083 181 1483 3903 3331 2363 756 558 2838 3984 1878 2667 3333 1473 2136 3499 3873 1437 3091 1287 948 46 3660 3003 1572 1185 2231 2622 257 3538 3632 3989 1180 3928 3144 1492 3941 3253 3498 2721 1036 22 1020 725 1431 3821 2248 2542 3659 2849 524 2967 1 2493 3620 2951 3584 1641 3873 2087 1506 1489 3064"; String[] split = hashes.split(" "); String query = ""; for (int i = 0; i < split.length; i++) { String s = split[i]; if (s.trim().length() > 0) query += " cl_ha:" + s.trim(); }//from w ww . j a va2 s . co m URL u = new URL(baseURL + "?q=" + URLEncoder.encode(query, "utf-8") + "&wt=xml&rows=500"); InputStream in = u.openStream(); SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); SolrResponseHandler dh = new SolrResponseHandler(); saxParser.parse(in, dh); ArrayList<ResultItem> results = dh.getResults(); // re-rank: }