List of usage examples for java.io IOException printStackTrace
public void printStackTrace()
From source file:ffx.autoparm.Minimize_2.java
/** * <p>/*from www . j a v a 2 s. c o m*/ * main</p> * * @param args an array of {@link java.lang.String} objects. */ public static void main(String args[]) { try { Minimize_2 m = new Minimize_2("/home/gchattree/Research/Compounds/s_test3_compounds/famotidine/ttt.xyz", null); m.minimize(0.1); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.yannick.GcmSender.java
public static void main(String[] args) { if (args.length < 1 || args.length > 2 || args[0] == null) { System.err.println("usage: ./gradlew run -Pargs=\"MESSAGE[,DEVICE_TOKEN]\""); System.err.println(""); System.err.println(/*from ww w .j av a2 s. c om*/ "Specify a test message to broadcast via GCM. If a device's GCM registration token is\n" + "specified, the message will only be sent to that device. Otherwise, the message \n" + "will be sent to all devices subscribed to the \"global\" topic."); System.err.println(""); System.err.println( "Example (Broadcast):\n" + "On Windows: .\\gradlew.bat run -Pargs=\"<Your_Message>\"\n" + "On Linux/Mac: ./gradlew run -Pargs=\"<Your_Message>\""); System.err.println(""); System.err.println("Example (Unicast):\n" + "On Windows: .\\gradlew.bat run -Pargs=\"<Your_Message>,<Your_Token>\"\n" + "On Linux/Mac: ./gradlew run -Pargs=\"<Your_Message>,<Your_Token>\""); System.exit(1); } try { // Prepare JSON containing the GCM message content. What to send and where to send. JSONObject jGcmData = new JSONObject(); JSONObject jData = new JSONObject(); jData.put("message", args[0].trim()); // Where to send GCM message. if (args.length > 1 && args[1] != null) { jGcmData.put("to", args[1].trim()); } else { jGcmData.put("to", "/topics/global"); } // What to send in GCM message. jGcmData.put("data", jData); // Create connection to send GCM Message request. URL url = new URL("https://android.googleapis.com/gcm/send"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("Authorization", "key=" + API_KEY); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestMethod("POST"); conn.setDoOutput(true); // Send GCM message content. OutputStream outputStream = conn.getOutputStream(); outputStream.write(jGcmData.toString().getBytes()); // Read GCM response. InputStream inputStream = conn.getInputStream(); String resp = IOUtils.toString(inputStream); System.out.println(resp); System.out.println("Check your device/emulator for notification or logcat for " + "confirmation of the receipt of the GCM message."); } catch (IOException e) { System.out.println("Unable to send GCM message."); System.out.println("Please ensure that API_KEY has been replaced by the server " + "API key, and that the device's registration token is correct (if specified)."); e.printStackTrace(); } }
From source file:lc.buyplus.gcmsender.GcmSender.java
public static void main(String[] args) throws JSONException { if (args.length < 1 || args.length > 2 || args[0] == null) { System.err.println("usage: ./gradlew run -Pmsg=\"MESSAGE\" [-Pto=\"DEVICE_TOKEN\"]"); System.err.println(""); System.err.println(/*from w w w . j a v a 2 s .co m*/ "Specify a test message to broadcast via GCM. If a device's GCM registration token is\n" + "specified, the message will only be sent to that device. Otherwise, the message \n" + "will be sent to all devices subscribed to the \"global\" topic."); System.err.println(""); System.err.println( "Example (Broadcast):\n" + "On Windows: .\\gradlew.bat run -Pmsg=\"<Your_Message>\"\n" + "On Linux/Mac: ./gradlew run -Pmsg=\"<Your_Message>\""); System.err.println(""); System.err.println("Example (Unicast):\n" + "On Windows: .\\gradlew.bat run -Pmsg=\"<Your_Message>\" -Pto=\"<Your_Token>\"\n" + "On Linux/Mac: ./gradlew run -Pmsg=\"<Your_Message>\" -Pto=\"<Your_Token>\""); System.exit(1); } try { // Prepare JSON containing the GCM message content. What to send and where to send. JSONObject jGcmData = new JSONObject(); JSONObject jData = new JSONObject(); jData.put("message", args[0].trim()); // Where to send GCM message. if (args.length > 1 && args[1] != null) { jGcmData.put("to", args[1].trim()); } else { jGcmData.put("to", "/topics/global"); } // What to send in GCM message. jGcmData.put("data", jData); // Create connection to send GCM Message request. URL url = new URL("https://android.googleapis.com/gcm/send"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("Authorization", "key=" + API_KEY); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestMethod("POST"); conn.setDoOutput(true); // Send GCM message content. OutputStream outputStream = conn.getOutputStream(); outputStream.write(jGcmData.toString().getBytes()); // Read GCM response. InputStream inputStream = conn.getInputStream(); String resp = IOUtils.toString(inputStream); System.out.println(resp); System.out.println("Check your device/emulator for notification or logcat for " + "confirmation of the receipt of the GCM message."); } catch (IOException e) { System.out.println("Unable to send GCM message."); System.out.println("Please ensure that API_KEY has been replaced by the server " + "API key, and that the device's registration token is correct (if specified)."); e.printStackTrace(); } }
From source file:com.pinch.console.GcmSender.java
public static void main(String[] args) { // if (args.length < 1 || args.length > 2 || args[0] == null) { // System.err.println("usage: ./gradlew run -Pmsg=\"MESSAGE\" [-Pto=\"DEVICE_TOKEN\"]"); // System.err.println(""); // System.err.println("Specify a test message to broadcast via GCM. If a device's GCM registration token is\n" + // "specified, the message will only be sent to that device. Otherwise, the message \n" + // "will be sent to all devices subscribed to the \"global\" topic."); // System.err.println(""); // System.err.println("Example (Broadcast):\n" + // "On Windows: .\\gradlew.bat run -Pmsg=\"<Your_Message>\"\n" + // "On Linux/Mac: ./gradlew run -Pmsg=\"<Your_Message>\""); // System.err.println(""); // System.err.println("Example (Unicast):\n" + // "On Windows: .\\gradlew.bat run -Pmsg=\"<Your_Message>\" -Pto=\"<Your_Token>\"\n" + // "On Linux/Mac: ./gradlew run -Pmsg=\"<Your_Message>\" -Pto=\"<Your_Token>\""); // System.exit(1); // }/* w w w . j a v a 2 s. c om*/ try { // Prepare JSON containing the GCM message content. What to send and where to send. JSONObject jGcmData = new JSONObject(); JSONObject jData = new JSONObject(); jData.put("message", "Saurabh Garg signed up!!"); jData.put("title", "New sign up!"); // Where to send GCM message. //if (args.length > 1 && args[1] != null) { jGcmData.put("to", "dOEmVpNPTCY:APA91bEkeYfFMhAraF4d87SJu12oxDElUp6KW1r710KSKeuDpW31Cd5_WExUxT16KNquJ69wwDMlxd-3qoEIeDNJNU1XjyXiXztOqlKglB-zdOlszoXhX9zIYmYNV8d4vWkM0oPwjlk9"); // } else { // jGcmData.put("to", "/topics/global"); // } // What to send in GCM message. jGcmData.put("data", jData); // Create connection to send GCM Message request. URL url = new URL("https://android.googleapis.com/gcm/send"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("Authorization", "key=" + API_KEY); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestMethod("POST"); conn.setDoOutput(true); // Send GCM message content. OutputStream outputStream = conn.getOutputStream(); outputStream.write(jGcmData.toString().getBytes()); // Read GCM response. InputStream inputStream = conn.getInputStream(); String resp = IOUtils.toString(inputStream); System.out.println(resp); System.out.println("Check your device/emulator for notification or logcat for " + "confirmation of the receipt of the GCM message."); } catch (IOException e) { System.out.println("Unable to send GCM message."); System.out.println("Please ensure that API_KEY has been replaced by the server " + "API key, and that the device's registration token is correct (if specified)."); e.printStackTrace(); } }
From source file:de.ipbhalle.metfusion.utilities.chemaxon.ChemAxonUtilities.java
public static void main(String[] args) { ChemAxonUtilities cau = new ChemAxonUtilities(true); URL url = cau.getClass().getResource("fcfp.xml"); System.out.println("file -> " + url.getFile()); System.out.println("path -> " + url.getPath()); ECFP one = cau.generateECFPFromName("O=P(c1ccccc1)(c2ccccc2)C"); ECFP two = cau.generateECFPFromName("O=P4(C1C3C2CC1C4C23)c5ccccc5"); System.out.println("tan test -> " + (1 - one.getTanimoto(two))); ECFPParameters params = new ECFPParameters(new File(url.getFile())); ECFPFeatureLookup lookup = new ECFPFeatureLookup(params); MolHandler mh = null;/*from w w w . j av a 2 s .c om*/ try { mh = new MolHandler("O=P(c1ccccc1)(c2ccccc2)C"); Molecule m = mh.getMolecule(); lookup.processMolecule(m); int[] arr = one.toIntArray(); for (int i = 0; i < arr.length; i++) { for (ECFPFeature f : lookup.getFeaturesFromIdentifier(arr[i])) { //System.out.println(f.getSubstructure().toFormat("SMARTS")); try { System.out.println(MolExporter.exportToFormat(f.getSubstructure(), "SMARTS")); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } catch (MolFormatException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); try { Fingerprinter fp = new Fingerprinter(); IAtomContainer ac1 = sp.parseSmiles("O=P(c1ccccc1)(c2ccccc2)C"); IAtomContainer ac2 = sp.parseSmiles("O=P4(C1C3C2CC1C4C23)c5ccccc5"); float tan = Tanimoto.calculate(fp.getFingerprint(ac1), fp.getFingerprint(ac2)); System.out.println("CDK tanimoto -> " + tan); } catch (InvalidSmilesException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (CDKException e) { // TODO Auto-generated catch block e.printStackTrace(); } ChemAxonUtilities cau2 = new ChemAxonUtilities(false); ECFP test = cau2.generateECFPFromMol(new File("/vol/massbank/Cache/PB/mol/PB000122.mol")); ECFP test2 = cau2.generateECFPFromMol(new File("/vol/massbank/Cache/PB/mol/PB000126.mol")); System.out.println("tanimoto dissimilarity -> " + test.getTanimoto(test2)); System.out.println("tanimoto similarity -> " + (1 - test.getTanimoto(test2))); }
From source file:gcm.play.android.samples.com.gcmquickstart.GcmSender.java
public static void main(String[] args) throws JSONException { if (args.length < 1 || args.length > 2 || args[0] == null) { System.err.println("usage: ./gradlew run -Pargs=\"MESSAGE[,DEVICE_TOKEN]\""); System.err.println(""); System.err.println(//w ww. j a va 2 s.c o m "Specify a test message to broadcast via GCM. If a device's GCM registration token is\n" + "specified, the message will only be sent to that device. Otherwise, the message \n" + "will be sent to all devices subscribed to the \"global\" topic."); System.err.println(""); System.err.println( "Example (Broadcast):\n" + "On Windows: .\\gradlew.bat run -Pargs=\"<Your_Message>\"\n" + "On Linux/Mac: ./gradlew run -Pargs=\"<Your_Message>\""); System.err.println(""); System.err.println("Example (Unicast):\n" + "On Windows: .\\gradlew.bat run -Pargs=\"<Your_Message>,<Your_Token>\"\n" + "On Linux/Mac: ./gradlew run -Pargs=\"<Your_Message>,<Your_Token>\""); System.exit(1); } try { // Prepare JSON containing the GCM message content. What to send and where to send. JSONObject jGcmData = new JSONObject(); JSONObject jData = new JSONObject(); jData.put("message", args[0].trim()); // Where to send GCM message. if (args.length > 1 && args[1] != null) { jGcmData.put("to", args[1].trim()); } else { jGcmData.put("to", "/topics/global"); } // What to send in GCM message. jGcmData.put("data", jData); // Create connection to send GCM Message request. URL url = new URL("https://android.googleapis.com/gcm/send"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("Authorization", "key=" + API_KEY); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestMethod("POST"); conn.setDoOutput(true); // Send GCM message content. OutputStream outputStream = conn.getOutputStream(); outputStream.write(jGcmData.toString().getBytes()); // Read GCM response. InputStream inputStream = conn.getInputStream(); String resp = IOUtils.toString(inputStream); System.out.println(resp); System.out.println("Check your device/emulator for notification or logcat for " + "confirmation of the receipt of the GCM message."); } catch (IOException e) { System.out.println("Unable to send GCM message."); System.out.println("Please ensure that API_KEY has been replaced by the server " + "API key, and that the device's registration token is correct (if specified)."); e.printStackTrace(); } }
From source file:com.pixa.gcmsender.GcmSender.java
public static void main(String[] args) { if (args.length < 1 || args.length > 2 || args[0] == null) { System.err.println("usage: ./gradlew run -Pmsg=\"MESSAGE\" [-Pto=\"DEVICE_TOKEN\"]"); System.err.println(""); System.err.println(/* w w w .j ava 2 s .c o m*/ "Specify a test message to broadcast via GCM. If a device's GCM registration token is\n" + "specified, the message will only be sent to that device. Otherwise, the message \n" + "will be sent to all devices subscribed to the \"global\" topic."); System.err.println(""); System.err.println( "Example (Broadcast):\n" + "On Windows: .\\gradlew.bat run -Pmsg=\"<Your_Message>\"\n" + "On Linux/Mac: ./gradlew run -Pmsg=\"<Your_Message>\""); System.err.println(""); System.err.println("Example (Unicast):\n" + "On Windows: .\\gradlew.bat run -Pmsg=\"<Your_Message>\" -Pto=\"<Your_Token>\"\n" + "On Linux/Mac: ./gradlew run -Pmsg=\"<Your_Message>\" -Pto=\"<Your_Token>\""); System.exit(1); } try { // Prepare JSON containing the GCM message content. What to send and where to send. JSONObject jGcmData = new JSONObject(); JSONObject jData = new JSONObject(); jData.put("message", args[0].trim()); // Where to send GCM message. if (args.length > 1 && args[1] != null) { jGcmData.put("to", args[1].trim()); } else { jGcmData.put("to", "/topics/global"); } // What to send in GCM message. jGcmData.put("data", jData); // Create connection to send GCM Message request. URL url = new URL("https://android.googleapis.com/gcm/send"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("Authorization", "key=" + API_KEY); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestMethod("POST"); conn.setDoOutput(true); // Send GCM message content. OutputStream outputStream = conn.getOutputStream(); outputStream.write(jGcmData.toString().getBytes()); // Read GCM response. InputStream inputStream = conn.getInputStream(); String resp = IOUtils.toString(inputStream); System.out.println(resp); System.out.println("Check your device/emulator for notification or logcat for " + "confirmation of the receipt of the GCM message."); } catch (IOException e) { System.out.println("Unable to send GCM message."); System.out.println("Please ensure that API_KEY has been replaced by the server " + "API key, and that the device's registration token is correct (if specified)."); e.printStackTrace(); } }
From source file:markov.java
/** * @param args/*from w w w . j a v a 2s .c o m*/ */ public static void main(String[] args) { // hack: eclipse don't support IO redirection worth a shit // try { // System.setIn(new FileInputStream("./json")); // } catch (FileNotFoundException e1) { // // TODO Auto-generated catch block // e1.printStackTrace(); // } boolean graphMode = false; boolean jsonMode = false; boolean jsonRecoverMode = false; boolean endNode = false; int count = -1; long n = 0; long sumOfSqr = 0; long sum = 0; for (String s : args) { if (!s.matches("^-[vegjJh]*(c[0-9]*)?$")) { System.out.println("invalid argument"); return; } if (s.matches("^-.*h.*")) { System.out.println(HELP); return; } if (s.matches("^-.*v.*")) { verbose = true; log("verbose mode"); } if (s.matches("^-.*g.*")) { graphMode = true; log("graph mode"); } if (s.matches("^-.*j.*")) { jsonMode = true; log("json mode"); } if (s.matches("^-.*J.*")) { jsonRecoverMode = true; log("json recover mode"); } if (s.matches("^-.*e.*")) { endNode = true; log("include end node"); } if (s.matches("^-.*c[0-9]*$")) { log("counted output mode"); count = Integer.parseInt(s.replaceAll("^-.*c", "")); } boolean error = (graphMode == true && jsonMode == true); if (!error) { error = (count > -1) && (graphMode == true || jsonMode == true); } if (error) { System.err.println("[error] switches j, g and, c are mutualy exclusive."); return; } } StateTransitionDiagram<Character> std; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { if (!jsonRecoverMode) { Trainer<Character> trainer = new Trainer<Character>(); String s = br.readLine(); while (s != null) { trainer.train(string2List(s)); n++; sumOfSqr += s.length() * s.length(); sum += s.length(); s = br.readLine(); } if (n == 0) { System.err .println("Invalid corpus: At least one sample is required, two to make it interesting"); return; } std = trainer.getTransitionDiagram(); } else { std = new StateTransitionDiagram<Character>(); GsonStub gstub = new Gson().fromJson(br, GsonStub.class); n = gstub.meta.n; sum = gstub.meta.sum; sumOfSqr = gstub.meta.sumOfSqr; for (Entry<String, StateStub> entry : gstub.states.entrySet()) { State<Character> state; if (entry.getKey().equals("null")) { state = std.getGuard(); } else { state = std.getState(Character.valueOf(entry.getKey().charAt(0))); } for (Entry<String, Integer> transitions : entry.getValue().transitions.entrySet()) { State<Character> tranny; if (transitions.getKey().equals("null")) { tranny = std.getGuard(); } else { tranny = std.getState(Character.valueOf(transitions.getKey().charAt(0))); } state.addTransition(tranny.getValue(), transitions.getValue()); } } } if (graphMode) { if (endNode) { System.out.println(std.toString()); } else { System.out.println(std.removeEndGuards().toString()); } return; } if (jsonMode) { Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); String partialJson; if (endNode) { partialJson = gson.toJson(std); } else { partialJson = gson.toJson(std.removeEndGuards()); } GsonStub gstub = new Gson().fromJson(partialJson, GsonStub.class); gstub.meta = new Meta(); gstub.meta.n = n; gstub.meta.sum = sum; gstub.meta.sumOfSqr = sumOfSqr; System.out.println(gson.toJson(gstub)); return; } Generator<Character> generator; if (endNode) { generator = new EndTagGenerator<Character>(std); } else { double sd = ((double) sumOfSqr - (double) (sum * sum) / (double) n) / (double) (n - 1); double mean = (double) sum / (double) n; log(String.format("mean: %.4f sd: %.4f", mean, sd)); NormalDistributionImpl dist = new NormalDistributionImpl(mean, sd); generator = new NormalizedGenerator<Character>(std.removeEndGuards(), dist); } if (count >= 0) { for (int c = 0; c < count; c++) { output(generator); } } else { while (true) { output(generator); } } } catch (IOException e) { e.printStackTrace(); } }
From source file:org.eclipse.swt.examples.browserexample.BrowserExample.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); shell.setText(getResourceString("window.title")); InputStream stream = BrowserExample.class.getResourceAsStream(iconLocation); Image icon = new Image(display, stream); shell.setImage(icon);//from w w w . j av a 2 s . com try { stream.close(); } catch (IOException e) { e.printStackTrace(); } BrowserExample app = new BrowserExample(shell, true); app.setShellDecoration(icon, true); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } icon.dispose(); app.dispose(); display.dispose(); }
From source file:com.pp.dcasajus.forkpoint.GcmSender.java
public static void main(String[] args) { if (args.length < 1 || args.length > 2 || args[0] == null) { System.err.println("usage: ./gradlew run -Pmsg=\"MESSAGE\" [-Pto=\"DEVICE_TOKEN\"]"); System.err.println(""); System.err.println(//w w w. j av a 2 s.co m "Specify a test message to broadcast via GCM. If a device's GCM registration token is\n" + "specified, the message will only be sent to that device. Otherwise, the message \n" + "will be sent to all devices subscribed to the \"global\" topic."); System.err.println(""); System.err.println( "Example (Broadcast):\n" + "On Windows: .\\gradlew.bat run -Pmsg=\"<Your_Message>\"\n" + "On Linux/Mac: ./gradlew run -Pmsg=\"<Your_Message>\""); System.err.println(""); System.err.println("Example (Unicast):\n" + "On Windows: .\\gradlew.bat run -Pmsg=\"<Your_Message>\" -Pto=\"<Your_Token>\"\n" + "On Linux/Mac: ./gradlew run -Pmsg=\"<Your_Message>\" -Pto=\"<Your_Token>\""); System.exit(1); } try { // Prepare JSON containing the GCM message content. What to send and where to send. JSONObject jGcmData = new JSONObject(); JSONObject jData = new JSONObject(); jData.put("message", args[0].trim()); // Where to send GCM message. if (args.length > 1 && args[1] != null) { jGcmData.put("to", args[1].trim()); } else { jGcmData.put("to", "/topics/global"); } // What to send in GCM message. jGcmData.put("data", jData); // Create connection to send GCM Message request. URL url = new URL("https://android.googleapis.com/gcm/send"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("Authorization", "key=" + API_KEY); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestMethod("POST"); conn.setDoOutput(true); // Send GCM message content. OutputStream outputStream = conn.getOutputStream(); outputStream.write(jGcmData.toString().getBytes()); // Read GCM response. InputStream inputStream = conn.getInputStream(); String resp = IOUtils.toString(inputStream); System.out.println(resp); System.out.println("Check your device/emulator for notification or logcat for " + "confirmation of the receipt of the GCM message."); } catch (IOException e) { System.out.println("Unable to send GCM message."); System.out.println("Please ensure that API_KEY has been replaced by the server " + "API key, and that the device's registration token is correct (if specified)."); e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } }