List of usage examples for java.lang Object toString
public String toString()
From source file:com.googlecode.dex2jar.bin_gen.BinGen.java
/** * @param args//from w ww . ja va 2 s . c o m * @throws IOException */ public static void main(String[] args) throws IOException { Properties p = new Properties(); p.load(BinGen.class.getResourceAsStream("class.cfg")); String bat = FileUtils.readFileToString( new File("src/main/resources/com/googlecode/dex2jar/bin_gen/bat_template"), "UTF-8"); String sh = FileUtils.readFileToString( new File("src/main/resources/com/googlecode/dex2jar/bin_gen/sh_template"), "UTF-8"); File binDir = new File("src/main/bin"); String setclasspath = FileUtils.readFileToString( new File("src/main/resources/com/googlecode/dex2jar/bin_gen/setclasspath.bat"), "UTF-8"); FileUtils.writeStringToFile(new File(binDir, "setclasspath.bat"), setclasspath, "UTF-8"); for (Object key : p.keySet()) { String name = key.toString(); FileUtils.writeStringToFile(new File(binDir, key.toString() + ".sh"), sh.replaceAll("__@class_name@__", p.getProperty(name)), "UTF-8"); FileUtils.writeStringToFile(new File(binDir, key.toString() + ".bat"), bat.replaceAll("__@class_name@__", p.getProperty(name)), "UTF-8"); } }
From source file:com.tbs.devcorner.simple.App.java
public static void main(String[] args) { try {//w w w.j a v a 2 s. c o m // Build Connection URL api_url = new URL("http://www.earthquakescanada.nrcan.gc.ca/api/earthquakes/"); URLConnection api = api_url.openConnection(); // Set HTTP Headers api.setRequestProperty("Accept", "application/json"); api.setRequestProperty("Accept-Language", "en"); // Get Response JSONTokener tokener = new JSONTokener(api.getInputStream()); JSONObject jsondata = new JSONObject(tokener); // Display API name System.out.println(jsondata.getJSONObject("metadata").getJSONObject("request").getJSONObject("name") .get("en").toString()); // Iterate over latest links JSONObject latest = jsondata.getJSONObject("latest"); for (Object item : latest.keySet()) { System.out.println(item.toString() + " -> " + latest.get(item.toString())); } } catch (MalformedURLException e) { System.out.println("Malformed URL"); } catch (IOException e) { System.out.println("IO Error"); } }
From source file:com.tbs.devcorner.simple.App.java
public static void main(String[] args) { try {//from w ww .j a v a2 s .com // Crer la connexion URL api_url = new URL("http://www.earthquakescanada.nrcan.gc.ca/api/earthquakes/"); URLConnection api = api_url.openConnection(); // Dfinir les en-ttes HTTP api.setRequestProperty("Accept", "application/json"); api.setRequestProperty("Accept-Language", "fr"); // Obtenir la rponse JSONTokener tokener = new JSONTokener(api.getInputStream()); JSONObject jsondata = new JSONObject(tokener); // Afficher le nom de lAPI System.out.println(jsondata.getJSONObject("metadata").getJSONObject("request").getJSONObject("name") .get("fr").toString()); // Rpter lopration sur les liens les plus rcents JSONObject latest = jsondata.getJSONObject("latest"); for (Object item : latest.keySet()) { System.out.println(item.toString() + " -> " + latest.get(item.toString())); } } catch (MalformedURLException e) { System.out.println("URL mal forme"); } catch (IOException e) { System.out.println("Erreur dE/S"); } }
From source file:Main.java
public static void main(String[] args) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(false); // never forget this! DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse("/data.xml"); XPathFactory xPathFactory = XPathFactory.newInstance(); XPath xpath = xPathFactory.newXPath(); XPathExpression xPathExpression = xpath.compile("//city/text()"); Object result = xPathExpression.evaluate(doc, XPathConstants.NODESET); System.out.println(result.toString()); NodeList nodes = (NodeList) result; System.out.println(nodes.getLength()); for (int i = 0; i < nodes.getLength(); i++) { System.out.println(nodes.item(i).getNodeValue()); }/* w w w .ja v a 2 s .com*/ }
From source file:Main.java
public static void main(String args[]) { String labels[] = { "A", "B", "C", "D", "E", "F", "G", "H" }; JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList<String> jlist = new JList<>(labels); JScrollPane scrollPane1 = new JScrollPane(jlist); f.add(scrollPane1, BorderLayout.CENTER); MouseListener mouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent mouseEvent) { JList<String> theList = (JList) mouseEvent.getSource(); if (mouseEvent.getClickCount() == 2) { int index = theList.locationToIndex(mouseEvent.getPoint()); if (index >= 0) { Object o = theList.getModel().getElementAt(index); System.out.println("Double-clicked on: " + o.toString()); }/*from www . j a v a2s . co m*/ } } }; jlist.addMouseListener(mouseListener); f.setSize(350, 200); f.setVisible(true); }
From source file:JListLocationToIndexSample.java
public static void main(String args[]) { String labels[] = { "A", "B", "C", "D", "E", "F", "G", "H" }; JFrame frame = new JFrame("Selecting JList"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList jlist = new JList(labels); JScrollPane scrollPane1 = new JScrollPane(jlist); frame.add(scrollPane1, BorderLayout.CENTER); MouseListener mouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent mouseEvent) { JList theList = (JList) mouseEvent.getSource(); if (mouseEvent.getClickCount() == 2) { int index = theList.locationToIndex(mouseEvent.getPoint()); if (index >= 0) { Object o = theList.getModel().getElementAt(index); System.out.println("Double-clicked on: " + o.toString()); }/*w w w . j a v a 2 s .com*/ } } }; jlist.addMouseListener(mouseListener); frame.setSize(350, 200); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { final String labels[] = { "A", "B", "C", "D", "E" }; JFrame frame = new JFrame("Selecting JList"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList jlist = new JList(labels); JScrollPane scrollPane1 = new JScrollPane(jlist); frame.add(scrollPane1);/*from w w w. j a v a 2 s . co m*/ MouseListener mouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent mouseEvent) { JList theList = (JList) mouseEvent.getSource(); if (mouseEvent.getClickCount() == 2) { int index = theList.locationToIndex(mouseEvent.getPoint()); if (index >= 0) { Object o = theList.getModel().getElementAt(index); System.out.println("Double-clicked on: " + o.toString()); } } } }; jlist.addMouseListener(mouseListener); frame.setSize(350, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { // create a date Date date = new Date(); // clone it to a second date Object date2 = date.clone(); // print the results System.out.println("Original Date:" + date.toString()); System.out.println("Cloned date :" + date2.toString()); }
From source file:SelectingJListSample.java
public static void main(String args[]) { String labels[] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }; JFrame frame = new JFrame("Selecting JList"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); JList jlist = new JList(labels); JScrollPane scrollPane1 = new JScrollPane(jlist); contentPane.add(scrollPane1, BorderLayout.WEST); ListSelectionListener listSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent listSelectionEvent) { System.out.print("First index: " + listSelectionEvent.getFirstIndex()); System.out.print(", Last index: " + listSelectionEvent.getLastIndex()); boolean adjust = listSelectionEvent.getValueIsAdjusting(); System.out.println(", Adjusting? " + adjust); if (!adjust) { JList list = (JList) listSelectionEvent.getSource(); int selections[] = list.getSelectedIndices(); Object selectionValues[] = list.getSelectedValues(); for (int i = 0, n = selections.length; i < n; i++) { if (i == 0) { System.out.print(" Selections: "); }/* w ww .j a va 2s. c om*/ System.out.print(selections[i] + "/" + selectionValues[i] + " "); } System.out.println(); } } }; jlist.addListSelectionListener(listSelectionListener); MouseListener mouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent mouseEvent) { JList theList = (JList) mouseEvent.getSource(); if (mouseEvent.getClickCount() == 2) { int index = theList.locationToIndex(mouseEvent.getPoint()); if (index >= 0) { Object o = theList.getModel().getElementAt(index); System.out.println("Double-clicked on: " + o.toString()); } } } }; jlist.addMouseListener(mouseListener); frame.setSize(350, 200); frame.setVisible(true); }
From source file:DataLoader.java
public static void main(String[] args) throws IOException, ValidationException, LicenseException, JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException { System.out.println(/*from w w w. j av a2 s.c om*/ "System is initialising. Please wait for a few seconds then type your queries below once you see the prompt (->)"); C24.init().withLicence("/biz/c24/api/license-ads.dat"); // Create our application context - assumes the Spring configuration is in the classpath in a file called spring-config.xml ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml"); // ======================================================================== // DEMO // A simple command-line interface to allow us to query the GemFire regions // ======================================================================== GemfireTemplate template = context.getBean(GemfireTemplate.class); BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in)); boolean writePrompt = true; try { while (true) { if (writePrompt) { System.out.print("-> "); System.out.flush(); writePrompt = false; } if (br.ready()) { try { String request = br.readLine(); System.out.println("Running: " + request); SelectResults<Object> results = template.find(request); System.out.println(); System.out.println("Result:"); for (Object result : results.asList()) { System.out.println(result.toString()); } } catch (Exception ex) { System.out.println("Error executing last command " + ex.getMessage()); //ex.printStackTrace(); } writePrompt = true; } else { // Wait for a second and try again try { Thread.sleep(1000); } catch (InterruptedException ioEx) { break; } } } } catch (IOException ioe) { // Write any exceptions to stderr System.err.print(ioe); } }