List of usage examples for java.lang Exception printStackTrace
public void printStackTrace()
From source file:MainClass.java
public static void main(String[] a) { FileReader fr;//from w w w .ja v a 2 s. c o m try { fr = new FileReader(new File("yourFile.txt")); BufferedReader br = new BufferedReader(fr); String line = br.readLine(); while (line != null) { System.out.println(line); line = br.readLine(); } br.close(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.amit.api.compiler.App.java
public static void main(String[] args) { Options options = createOptions();/*from w w w .j a v a 2s . co m*/ CommandLineParser parser = new GnuParser(); try { // parse the command line arguments CommandLine cmd = parser.parse(options, args); execute(cmd); } catch (ParseException exp) { System.out.println("Invalid arguments. Reason: " + exp.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("args", options); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { Connection conn = null;/*from w ww . j a v a2 s .c o m*/ Statement stmt = null; ResultSet rs = null; try { conn = getConnection(); String query = "select id, name from employees"; stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs = stmt.executeQuery(query); while (rs.next()) { String id = rs.getString(1); String name = rs.getString(2); System.out.println("id=" + id + " name=" + name); } rs.first(); rs.deleteRow(); rs.beforeFirst(); while (rs.next()) { String id = rs.getString(1); String name = rs.getString(2); System.out.println("id=" + id + " name=" + name); } } catch (Exception e) { e.printStackTrace(); System.exit(1); } finally { try { rs.close(); stmt.close(); conn.close(); } catch (SQLException e) { e.printStackTrace(); } } }
From source file:MainClass.java
public static void main(String[] args) throws IOException { SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); SSLServerSocket ss = (SSLServerSocket) ssf.createServerSocket(8080); ss.setNeedClientAuth(true);/*w w w . ja v a 2 s.c o m*/ while (true) { try { Socket s = ss.accept(); OutputStream out = s.getOutputStream(); BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream())); String line = null; while (((line = in.readLine()) != null) && (!("".equals(line)))) { System.out.println(line); } System.out.println(""); StringBuffer buffer = new StringBuffer(); buffer.append("<HTML>\n"); buffer.append("<HEAD><TITLE>HTTPS Server</TITLE></HEAD>\n"); buffer.append("<BODY>\n"); buffer.append("<H1>Success!</H1>\n"); buffer.append("</BODY>\n"); buffer.append("</HTML>\n"); String string = buffer.toString(); byte[] data = string.getBytes(); out.write("HTTP/1.0 200 OK\n".getBytes()); out.write(new String("Content-Length: " + data.length + "\n").getBytes()); out.write("Content-Type: text/html\n\n".getBytes()); out.write(data); out.flush(); out.close(); in.close(); s.close(); } catch (Exception e) { e.printStackTrace(); } } }
From source file:test.gov.nih.nci.system.web.client.HardDriveClient.java
public static void main(String[] args) { try {/*from w w w . j ava 2 s. co m*/ Computer computer = new Computer(); computer.setType("DellPC"); computer.setId(9); HardDrive hardDrive = new HardDrive(); hardDrive.setComputer(computer); hardDrive.setSize(Integer.valueOf(1000)); if (args == null || args.length != 1) { System.out.println("Usage: RESTFulReadClient <RESTful resource URL>"); return; } String url = args[0]; File myFile = marshall(hardDrive); RESTfulCreateClient client = new RESTfulCreateClient(); client.create(myFile, url); } catch (Exception e) { e.printStackTrace(); } }
From source file:test.gov.nih.nci.system.web.client.OrderLineCreateClient.java
public static void main(String[] args) { try {// ww w.j av a 2 s . co m OrderLine line = new OrderLine(); line.setName("Microsoft"); if (args == null || args.length != 1) { System.out.println("Usage: RESTFulReadClient <RESTful resource URL>"); return; } String url = args[0]; File myFile = marshall(line); RESTfulCreateClient client = new RESTfulCreateClient(); Response response = client.create(myFile, url); String resStr = (String) response.getEntity(); } catch (Exception e) { e.printStackTrace(); } }
From source file:test.gov.nih.nci.system.web.client.ProductUpdateClient.java
public static void main(String[] args) { try {/* w ww. j a v a 2 s . c o m*/ Product product = new Product(); product.setName("IPad2"); OrderLine line = new OrderLine(); line.setName("IPad"); line.setId(Integer.valueOf(6)); product.setLine(line); if (args == null || args.length != 1) { System.out.println("Usage: RESTFulReadClient <RESTful resource URL>"); return; } String url = args[0]; File myFile = marshall(product); RESTfulUpdateClient client = new RESTfulUpdateClient(); client.update(myFile, url); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.huateng.ebank.framework.util.ApplicationContextUtils.java
public static void main(String[] argv) { try {/*from w ww . j a va 2s . c o m*/ //ApplicationContextUtils.getApplicationContext(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:GetColumnNamesFromResultSet_Oracle.java
public static void main(String[] args) { Connection conn = null;/*from w w w . j av a 2 s. c o m*/ Statement stmt = null; ResultSet rs = null; try { conn = getConnection(); // prepare query String query = "select id, name, age from employees"; // create a statement stmt = conn.createStatement(); // execute query and return result as a ResultSet rs = stmt.executeQuery(query); // get the column names from the ResultSet getColumnNames(rs); } catch (Exception e) { e.printStackTrace(); } finally { // release database resources try { rs.close(); stmt.close(); conn.close(); } catch (SQLException e) { e.printStackTrace(); } } }
From source file:de.tum.i13.ConvertCsvToProtobuf.java
public static void main(String args[]) { try {// w ww .ja v a 2 s . com LineIterator it = FileUtils.lineIterator(new File("/Users/manit/Projects/sdcbenchmark/Dataset/debscsv"), "UTF-8"); FileOutputStream out = new FileOutputStream("/Users/manit/Projects/sdcbenchmark/Dataset/debsprotobuf", true); while (it.hasNext()) { String csvLine = (String) it.next(); byte[] csvLineBytes = csvLine.getBytes(); String line = new String(csvLineBytes, StandardCharsets.UTF_8); Debs2015Protos.Taxitrip.Builder builder = Debs2015Protos.Taxitrip.newBuilder(); String[] splitted = line.split(","); builder.setMedallion(splitted[0]); builder.setHackLicense(splitted[1]); builder.setPickupDatetime(splitted[2]); builder.setDropoffDatetime(splitted[3]); builder.setTripTimeInSecs(Integer.parseInt(splitted[4])); builder.setTripDistance(Float.parseFloat(splitted[5])); builder.setPickupLongitude(Float.parseFloat(splitted[6])); builder.setPickupLatitude(Float.parseFloat(splitted[7])); builder.setDropoffLongitude(Float.parseFloat(splitted[8])); builder.setDropoffLatitude(Float.parseFloat(splitted[9])); builder.setPaymentType(splitted[10]); builder.setFareAmount(Float.parseFloat(splitted[11])); builder.setSurcharge(Float.parseFloat(splitted[12])); builder.setMtaTax(Float.parseFloat(splitted[13])); builder.setTipAmount(Float.parseFloat(splitted[14])); builder.setTollsAmount(Float.parseFloat(splitted[15])); builder.setTotalAmount(Float.parseFloat(splitted[16])); builder.build().writeDelimitedTo(out); } out.close(); } catch (Exception e) { e.printStackTrace(); } }