List of usage examples for java.lang System err
PrintStream err
To view the source code for java.lang System err.
Click Source Link
From source file:MainClass.java
public static void main(String[] args) { for (int i = 0; i < args.length; i++) { try {//from ww w. j a v a2 s. c o m InputStream fin = new FileInputStream(args[i]); OutputStream fout = new FileOutputStream(args[i] + GZIP_SUFFIX); GZIPOutputStream gzout = new GZIPOutputStream(fout); for (int c = fin.read(); c != -1; c = fin.read()) { gzout.write(c); } gzout.close(); } catch (IOException ex) { System.err.println(ex); } } }
From source file:DynaBeansExampleV2.java
public static void main(String args[]) throws Exception { Connection conn = getConnection(); PreparedStatement ps = conn/* w w w .j a v a 2s. c o m*/ .prepareStatement("SELECT * from movie, person " + "WHERE movie.director = person.Id"); ResultSet rs = ps.executeQuery(); ResultSetDynaClass rsdc = new ResultSetDynaClass(rs); Iterator itr = rsdc.iterator(); while (itr.hasNext()) { DynaBean bean = (DynaBean) itr.next(); System.err.println(bean.get("title")); } conn.close(); }
From source file:TestObjectPool.java
public static void main(String args[]) throws Exception { GenericObjectPool pool = new GenericObjectPool(); pool.setFactory(new EmployeeFactory()); /*First way of initializing pool pool.setMinIdle(5);/*from w w w. ja va2 s.c om*/ pool.setTimeBetweenEvictionRunsMillis(500); Thread.currentThread().sleep(600);*/ /* second, and preferred way */ for(int i = 0; i < 5; ++i) { pool.addObject(); } // pool.setTestOnReturn(true); pool.setMinEvictableIdleTimeMillis(1000); pool.setTimeBetweenEvictionRunsMillis(600); System.err.println("Number of employees in pool: " + pool.getNumIdle()); Thread.currentThread().sleep(1500); Employee employee = (Employee)pool.borrowObject(); employee.setName("Fred Flintstone"); employee.doWork(); System.err.println("Employee: " + employee); pool.returnObject(employee); System.err.println("Number of employees in pool: " + pool.getNumIdle()); }
From source file:RegisterFontPDF.java
public static void main(String[] args) { FontFactory.register("c:\\windows\\fonts\\comicbd.ttf"); FontFactory.register("c:\\windows\\fonts\\comic.ttf"); try {//from w w w. j a v a 2 s . c om System.out.println("These fonts were registered at the FontFactory:"); for (Iterator i = FontFactory.getRegisteredFonts().iterator(); i.hasNext();) { System.out.println(i.next()); } System.out.println("These are the families these fonts belong to:"); for (Iterator i = FontFactory.getRegisteredFamilies().iterator(); i.hasNext();) { System.out.println((String) i.next()); } } catch (Exception e) { System.err.println(e.getMessage()); } }
From source file:lookForPorts2.java
public static void main(String[] args) { Socket theSocket;/*from w w w. j a v a 2 s. c o m*/ String host = "localhost"; if (args.length > 0) { host = args[0]; } try { InetAddress theAddress = InetAddress.getByName(host); for (int i = 1024; i < 65536; i++) { try { System.out.println("Looking for port " + i); theSocket = new Socket(theAddress, i); System.out.println("There is a server on port " + i + " of " + host); } catch (IOException e) { // must not be a server on this port } } } catch (UnknownHostException e) { System.err.println(e); } }
From source file:com.idega.util.Stripper.java
public static void main(String[] args) { // Stripper stripper1 = new Stripper(); if (args.length != 2) { System.err.println("Auli. tt a hafa tvo parametra me essu, innskr og tskr"); return;//from w ww .jav a 2 s . c o m } BufferedReader in = null; BufferedWriter out = null; try { in = new BufferedReader(new FileReader(args[0])); } catch (java.io.FileNotFoundException e) { System.err.println("Auli. Error : " + e.toString()); return; } try { out = new BufferedWriter(new FileWriter(args[1])); } catch (java.io.IOException e) { System.err.println("Auli. Error : " + e.toString()); IOUtils.closeQuietly(in); return; } try { String input = in.readLine(); int count = 0; while (input != null) { int index = input.indexOf("\\CVS\\"); if (index > -1) { System.out.println("Skipping : " + input); count++; } else { out.write(input); out.newLine(); } input = in.readLine(); } System.out.println("Skipped : " + count); } catch (java.io.IOException e) { System.err.println("Error reading or writing file : " + e.toString()); } try { in.close(); out.close(); } catch (java.io.IOException e) { System.err.println("Error closing files : " + e.toString()); } }
From source file:ZapfDingbatsLists.java
public static void main(String[] args) { Document document = new Document(); try {// w w w .j a va 2 s .c om PdfWriter.getInstance(document, new FileOutputStream("ZapfDingbatsLists.pdf")); document.open(); ZapfDingbatsList z = new ZapfDingbatsList(42, 15); z.add(new ListItem("first item")); z.add(new ListItem("second item")); for (int i = 3; i < 20; i++) { z.add(i + "th item"); } document.add(z); document.newPage(); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { try {/*from w w w. jav a2 s . c o m*/ String url = "jdbc:odbc:yourdatabasename"; String driver = "sun.jdbc.odbc.JdbcOdbcDriver"; String user = "guest"; String password = "guest"; Class.forName(driver); Connection connection = DriverManager.getConnection(url, user, password); DatabaseMetaData meta = connection.getMetaData(); System.out.println("We are using " + meta.getDatabaseProductName()); System.out.println("Version is " + meta.getDatabaseProductVersion()); connection.close(); } catch (Exception e) { System.err.println(e); } }
From source file:UnicodeExamplePDF.java
public static void main(String[] args) { Document document = new Document(); try {//from w w w . j a v a 2s .com PdfWriter.getInstance(document, new FileOutputStream("UnicodeExamplePDF.pdf")); document.open(); BaseFont bfComic = BaseFont.createFont("c:\\windows\\fonts\\arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); document.add(new Paragraph("Unicode: \u0418", new Font(bfComic, 12))); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:NewPagePageEmptyPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w w w.j av a2 s . c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("NewPagePageEmptyPDF.pdf")); document.open(); document.add(new Paragraph("A")); document.newPage(); document.add(new Paragraph("B")); document.newPage(); document.add(Chunk.NEWLINE); document.newPage(); document.newPage(); document.add(new Paragraph("C")); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }