List of usage examples for java.lang StringBuilder append
@Override public StringBuilder append(double d)
From source file:Main.java
public static void main(String[] args) { String input = "This is a sentence"; char[] charinput = input.toCharArray(); Stack<String> stack = new Stack<String>(); for (int i = input.length() - 1; i >= 0; i--) { stack.push(String.valueOf(charinput[i])); }/*w ww . j a v a 2 s .c o m*/ StringBuilder StackPush = new StringBuilder(); for (int i = 0; i < stack.size(); i++) { StackPush.append(stack.get(i)); } System.out.println(StackPush.toString()); }
From source file:Main.java
public static void main(String[] args) { Calendar now = Calendar.getInstance(); Date nowDate = now.getTime(); long twoHoursByMillis = 2 * HOUR; long thirtyMinutesByMillis = 30 * MINUTE; Date twoHoursAndThirtyMinutesFromNow = new Date(twoHoursByMillis + thirtyMinutesByMillis); System.out.println(String.format("now %s and later %s", nowDate, twoHoursAndThirtyMinutesFromNow)); long ms = 10304004543l; StringBuilder text = new StringBuilder(""); if (ms > DAY) { text.append(ms / DAY).append(" days "); ms %= DAY;/*from w ww . j av a2s. c o m*/ } if (ms > HOUR) { text.append(ms / HOUR).append(" hours "); ms %= HOUR; } if (ms > MINUTE) { text.append(ms / MINUTE).append(" minutes "); ms %= MINUTE; } if (ms > SECOND) { text.append(ms / SECOND).append(" seconds "); ms %= SECOND; } text.append(ms + " ms"); System.out.println(text.toString()); }
From source file:Main.java
public static void main(String[] arg) { StringBuilder buffer = new StringBuilder(); char[] chars = new char[] { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm' }; buffer.append(chars); System.out.println(buffer);// w w w . j a va 2 s . c om }
From source file:net.vnt.ussdapp.util.ContextTest.java
public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "/context.xml" }); ContextProperties ctxProp = (ContextProperties) Context.getInstance().getBean("ContextProperties"); TXTParser parser = (TXTParser) Context.getInstance().getBean("TXTParser"); String mainmenu = ctxProp.getProperty("ussdapp.wrong"); try {// w w w . ja v a 2 s . co m Vector<String> vs = parser.readFields(mainmenu); Enumeration<String> ens = vs.elements(); StringBuilder sb = new StringBuilder(); while (ens.hasMoreElements()) { sb.append(ens.nextElement()).append("\n"); } System.out.println(sb.toString()); } catch (IOException ex) { Logger.getLogger(ContextTest.class.getName()).log(Level.SEVERE, null, ex); } System.out.println(System.getProperty("os.arch")); }
From source file:org.kuali.kfs.rest.AccountingPeriodCloseJob.java
public static void main(String[] args) { try {//from w w w. j av a2 s. c o m DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost request = new HttpPost("http://localhost:8080/kfs-dev/coa/accounting_periods/close"); request.addHeader("accept", "application/json"); request.addHeader("content-type", "application/json"); request.addHeader("authorization", "NSA_this_is_for_you"); StringBuilder sb = new StringBuilder(); sb.append("{"); sb.append("\"description\":\"Document: The Next Generation\","); sb.append("\"universityFiscalYear\": 2016,"); sb.append("\"universityFiscalPeriodCode\": \"03\""); sb.append("}"); StringEntity data = new StringEntity(sb.toString()); request.setEntity(data); HttpResponse response = httpClient.execute(request); System.out.println("Status Code: " + response.getStatusLine().getStatusCode()); if (response.getStatusLine().getStatusCode() != 200) { throw new RuntimeException( "Failed : HTTP error code : " + response.getStatusLine().getStatusCode()); } BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { System.out.println(output); } httpClient.getConnectionManager().shutdown(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { // Create an empty StringBuffer StringBuilder sb = new StringBuilder(); printDetails(sb);/*w w w . j a va 2 s .c om*/ // Append "good" sb.append("good"); printDetails(sb); // Insert "Hi " in the beginning sb.insert(0, "Hi "); printDetails(sb); // Delete the first o sb.deleteCharAt(1); printDetails(sb); // Append " be with you" sb.append(" be with you"); printDetails(sb); // Set the length to 3 sb.setLength(3); printDetails(sb); // Reverse the content sb.reverse(); printDetails(sb); }
From source file:be.dnsbelgium.rdap.client.ManGenerator.java
public static void main(String[] args) { Options options = new RDAPOptions(Locale.ENGLISH); Iterator<Option> it = options.getOptions().iterator(); StringBuilder sb = new StringBuilder(); while (it.hasNext()) { Option option = it.next(); sb.append(String.format(".IP \"%s\"\n%s\n", getOptionString(option), option.getDescription() == null ? "" : option.getDescription())); }/*from w ww . j a va 2 s .c o m*/ System.out.println(sb.toString()); }
From source file:com.berrysys.ussdgw.Starter.java
/** * The main method.//from ww w .ja v a 2 s . c o m * * @param args the arguments * @throws IOException Signals that an I/O exception has occurred. */ public static void main(String[] args) throws IOException { StringBuilder banner = new StringBuilder(); banner.append("\n").append(" ____ ____ \n") .append(" | __ ) ___ _ __ _ __ _ _/ ___| _ _ ___ \n") .append(" | _ \\ / _ \\ '__| '__| | | \\___ \\| | | / __|\n") .append(" | |_) | __/ | | | | |_| |___) | |_| \\__ \\\n") .append(" |____/ \\___|_| _|_| \\__, |____/ \\__, |___/\n") .append(" / ___|(_) __ _| |_ _ _|___/_ _ __ |___/ \n") .append(" \\___ \\| |/ _` | __| '__/ _` | '_ \\ \n") .append(" ___) | | (_| | |_| | | (_| | | | | \n") .append(" |____/|_|\\__, |\\__|_| \\__,_|_| |_| \n") .append(" _ _ __|___/__ ____ \n") .append(" | | | / ___/ ___|| _ \\ \n") .append(" | | | \\___ \\___ \\| | | | \n") .append(" | |_| |___) |__) | |_| | \n") .append(" \\___/|____/____/|____/ \n") .append(" / ___| __ _| |_ _____ ____ _ _ _ \n") .append(" | | _ / _` | __/ _ \\ \\ /\\ / / _` | | | | \n") .append(" | |_| | (_| | || __/\\ V V / (_| | |_| | \n") .append(" \\____|\\__,_|\\__\\___| \\_/\\_/ \\__,_|\\__, |\n") .append(" |___/ \n"); String berrysysUssdGW = banner.toString(); log.info(berrysysUssdGW); ApplicationContext applicationContext = new ClassPathXmlApplicationContext("/app-context.xml"); List<DialogListener> serverList = (List<DialogListener>) applicationContext.getBean("sctpServerList"); Iterator<DialogListener> i = serverList.iterator(); while (i.hasNext()) { final DialogListener dialogListenerItem = i.next(); DialogListenerThread dialogListenerThread = new DialogListenerThread(); dialogListenerThread.setDialogListener(dialogListenerItem); dialogListenerThread.start(); ThreadHolder.getInstance().getDialogListenerThreadList().add(dialogListenerThread); } Iterator<DialogListenerThread> j = ThreadHolder.getInstance().getDialogListenerThreadList().iterator(); while (j.hasNext()) { try { j.next().join(); } catch (InterruptedException e) { log.catching(e); } } }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JFileChooser fc = new JFileChooser(); fc.setMultiSelectionEnabled(true);//from w w w.j a v a2 s . c o m fc.setCurrentDirectory(new File("C:\\tmp")); JButton btn1 = new JButton("Show Dialog"); btn1.addActionListener(e -> fc.showDialog(frame, "Choose")); JButton btn2 = new JButton("Show Open Dialog"); btn2.addActionListener(e -> { int retVal = fc.showOpenDialog(frame); if (retVal == JFileChooser.APPROVE_OPTION) { File[] selectedfiles = fc.getSelectedFiles(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < selectedfiles.length; i++) { sb.append(selectedfiles[i].getName()); sb.append("\n"); } JOptionPane.showMessageDialog(frame, sb.toString()); } }); JButton btn3 = new JButton("Show Save Dialog"); btn3.addActionListener(e -> fc.showSaveDialog(frame)); Container pane = frame.getContentPane(); pane.setLayout(new GridLayout(3, 1, 10, 10)); pane.add(btn1); pane.add(btn2); pane.add(btn3); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:is.java
public static void main(String[] args) { List<Integer> list = Arrays.asList(3, 2, 4, 1, 5); NavigableSet<Integer> ns = new TreeSet<Integer>(list); System.out.println("Ascending order (default): " + ns); Iterator<Integer> descendingIterator = ns.descendingIterator(); StringBuilder sb = new StringBuilder("Descending order: "); while (descendingIterator.hasNext()) { int m = descendingIterator.next(); sb.append(m + " "); }/*from w w w . j a v a 2 s. c o m*/ System.out.println(sb); int greatest = ns.lower(3); System.out.println("Lower of 3 = " + greatest); int smallest = ns.higher(3); System.out.println("Higher of 3 = " + smallest); }