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:com.mycompany.hellomaven.helloWord.java
public static void main(String[] args) { final String json = "{\"employees\": [{\"firstName\": \"John\",\"lastName\": \"Doe\"},{\"firstName\": \"Anna\",\"lastName\": \"Smith\"},{\"firstName\": \"Peter\",\"lastName\": \"Jones\"}]}"; JSONObject jsonObject = new JSONObject(json); boolean has = jsonObject.has("employees"); if (has) {//from w ww . j a v a2 s. c o m System.err.println(jsonObject.getJSONArray("employees")); JSONArray array = jsonObject.getJSONArray("employees"); for (int i = 0; i < array.length(); i++) { JSONObject obj = array.getJSONObject(i); System.out.println(obj.getString("firstName")); } } }
From source file:FontFactoryStylesBoldPDF.java
public static void main(String[] args) { Document document = new Document(); try {//from w w w .j a va2 s .c o m PdfWriter.getInstance(document, new FileOutputStream("FontFactoryStylesBoldPDF.pdf")); document.open(); FontFactory.register("c:\\windows\\fonts\\arialbd.ttf"); document.add(new Phrase("bold ", FontFactory.getFont("Arial", 8, Font.BOLD))); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:HttpClientParameter.java
public static void main(String args[]) throws Exception { HttpClient client = new HttpClient(); client.getParams().setParameter("http.useragent", "My Browser"); HostConfiguration host = client.getHostConfiguration(); host.setHost("www.google.com"); GetMethod method = new GetMethod("http://www.yahoo.com"); int returnCode = client.executeMethod(host, method); System.err.println(method.getResponseBodyAsString()); System.err/*from www . j av a2 s . co m*/ .println("User-Agent: " + method.getHostConfiguration().getParams().getParameter("http.useragent")); System.err.println("User-Agent: " + method.getParams().getParameter("http.useragent")); method.releaseConnection(); }
From source file:Main.java
public static void main(String[] args) { Path basedir = FileSystems.getDefault().getPath("C:/tutorial/tmp/"); String tmp_dir_prefix = "Swing_"; //get the default temporary folders path String default_tmp = System.getProperty("java.io.tmpdir"); System.out.println(default_tmp); try {/* w ww . ja va 2 s. com*/ //set a prefix Path tmp_2 = Files.createTempDirectory(tmp_dir_prefix); System.out.println("TMP: " + tmp_2.toString()); } catch (IOException e) { System.err.println(e); } }
From source file:MainClass.java
public static void main(String[] args) { String phrase = new String("text\n"); String dirname = "C:/test"; // Directory name String filename = "byteData.txt"; File aFile = new File(dirname, filename); // Create the file output stream FileOutputStream file = null; try {//from w ww . j a v a 2 s . c om file = new FileOutputStream(aFile, true); } catch (FileNotFoundException e) { e.printStackTrace(System.err); } FileChannel outChannel = file.getChannel(); ByteBuffer buf = ByteBuffer.allocate(phrase.length()); byte[] bytes = phrase.getBytes(); buf.put(bytes); buf.flip(); try { outChannel.write(buf); file.close(); } catch (IOException e) { e.printStackTrace(System.err); } }
From source file:ImageScalingAbsolutePDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w w w . j a v a2s .co m*/ PdfWriter.getInstance(document, new FileOutputStream("ImageScalingAbsolutePDF.pdf")); document.open(); Image png = Image.getInstance("logo.png"); png.scaleAbsolute(160, 120); document.add(png); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:ImagesBMPPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from ww w .j av a2 s. c o m*/ PdfWriter.getInstance(document, new FileOutputStream("ImagesBMPPDF.pdf")); document.open(); document.add(new Paragraph("load a BMP image file")); Image img = Image.getInstance("logo.BMP"); document.add(img); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:MainClass.java
public static void main(String[] args) { long[] primes = new long[] { 1, 2, 3, 5, 7 }; File aFile = new File("C:/test/primes.txt"); FileOutputStream outputFile = null; try {/*from ww w. j a va 2 s . c om*/ outputFile = new FileOutputStream(aFile); } catch (FileNotFoundException e) { e.printStackTrace(System.err); } FileChannel file = outputFile.getChannel(); final int BUFFERSIZE = 100; ByteBuffer buf = ByteBuffer.allocate(BUFFERSIZE); DoubleBuffer doubleBuf = buf.asDoubleBuffer(); buf.position(8); CharBuffer charBuf = buf.asCharBuffer(); for (long prime : primes) { String primeStr = "prime = " + prime; doubleBuf.put(0, (double) primeStr.length()); charBuf.put(primeStr); buf.position(2 * charBuf.position() + 8); LongBuffer longBuf = buf.asLongBuffer(); longBuf.put(prime); buf.position(buf.position() + 8); buf.flip(); try { file.write(buf); } catch (IOException e) { e.printStackTrace(System.err); } buf.clear(); doubleBuf.clear(); charBuf.clear(); } try { System.out.println("File written is " + file.size() + "bytes."); outputFile.close(); } catch (IOException e) { e.printStackTrace(System.err); } }
From source file:ImagesTIFPDF.java
public static void main(String[] args) { Document document = new Document(); try {/* www .ja v a2s . com*/ PdfWriter.getInstance(document, new FileOutputStream("ImagesTIFPDF.pdf")); document.open(); document.add(new Paragraph("load a tif image file")); Image img = Image.getInstance("logo.tif"); document.add(img); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:ImagesGIFPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w ww.j av a2s .co m*/ PdfWriter.getInstance(document, new FileOutputStream("ImagesGIFPDF.pdf")); document.open(); document.add(new Paragraph("load a gif image file")); Image img = Image.getInstance("logo.gif"); document.add(img); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }