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:ListWithLongTextLineHTML.java
public static void main(String[] args) { Document document = new Document(); try {/* w ww .j a v a 2s . co m*/ HtmlWriter.getInstance(document, new FileOutputStream("ListWithLongTextLineHTML.html")); document.open(); List list = new List(true, 20); list.add(new ListItem("First line")); list.add(new ListItem( "Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text ")); list.add(new ListItem("Third line")); document.add(list); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:FileCopy.java
/** The main() method of the standalone program. Calls copy(). */ public static void main(String[] args) { if (args.length != 2) // Check arguments System.err.println("Usage: java FileCopy <source> <destination>"); else {// w w w . j ava 2 s . c o m // Call copy() to do the copy; display any error messages try { copy(args[0], args[1]); } catch (IOException e) { System.err.println(e.getMessage()); } } }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Simple Attributes"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); StyledDocument document = new DefaultStyledDocument(); SimpleAttributeSet attributes = new SimpleAttributeSet(); attributes.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.FALSE); attributes.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.FALSE); attributes.addAttribute(StyleConstants.CharacterConstants.Foreground, Color.LIGHT_GRAY); try {/* www.j a va2 s . co m*/ document.insertString(document.getLength(), " Bold, Italic and light gray color", attributes); } catch (BadLocationException badLocationException) { System.err.println("Bad insert"); } JTextPane textPane = new JTextPane(document); textPane.setEditable(false); JScrollPane scrollPane = new JScrollPane(textPane); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:TwoNestedTablesPDF.java
public static void main(String[] args) { Document document = new Document(); try {//from w ww .j ava2 s . co m PdfWriter.getInstance(document, new FileOutputStream("TwoNestedTablesPDF.pdf")); document.open(); Table secondTable = new Table(2); secondTable.addCell("0.0"); secondTable.addCell("0.1"); secondTable.addCell("1.0"); secondTable.addCell("1.1"); Table aTable = new Table(4, 4); // 4 rows, 4 columns aTable.setAutoFillEmptyCells(true); aTable.addCell("2.2", new Point(2, 2)); aTable.insertTable(secondTable, new Point(3, 3)); aTable.addCell("2.1", new Point(2, 1)); aTable.insertTable(secondTable, new Point(1, 3)); document.add(aTable); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:utilities.HashPassword.java
public static void main(String[] args) throws IOException { Md5PasswordEncoder encoder;/*from w w w . java2 s . c om*/ ConsoleReader reader; String line, hash; try { System.out.printf("HashPassword 1.3%n"); System.out.printf("----------------%n%n"); encoder = new Md5PasswordEncoder(); reader = new ConsoleReader(); line = reader.readLine(); while (!line.equals("quit")) { hash = encoder.encodePassword(line, null); System.out.println(hash); line = reader.readLine(); } } catch (Throwable oops) { System.out.flush(); System.err.printf("%n%s%n", oops.getLocalizedMessage()); //oops.printStackTrace(System.out); } }
From source file:TableCellAlignmentPDF.java
public static void main(String[] args) { Document.compress = false;/*from ww w . j ava 2s .c o m*/ Document document = new Document(); try { PdfWriter.getInstance(document, new FileOutputStream("TableCellAlignmentPDF.pdf")); document.open(); Image img = Image.getInstance("logo.png"); img.scalePercent(10); PdfPTable table = new PdfPTable(3); PdfPCell cell = new PdfPCell(); cell.addElement(new Chunk("cell ")); cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell("a cell"); table.addCell(cell); table.addCell("a cell"); document.add(table); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:JumpLocalDestinationPDF.java
public static void main(String[] args) { Document document = new Document(); try {//from w w w . ja v a2s . c o m PdfWriter.getInstance(document, new FileOutputStream("JumpLocalDestinationPDF.pdf")); document.open(); Paragraph paragraph = new Paragraph(); Anchor anchor1 = new Anchor("some text", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE, new Color(0, 0, 255))); anchor1.setName("top"); paragraph.add(anchor1); document.add(paragraph); Anchor anchor2 = new Anchor("please jump to a local destination", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 255))); anchor2.setReference("#top"); document.add(anchor2); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:JTextPaneWithIcon.java
public static void main(String args[]) { JFrame frame = new JFrame("TextPane Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); StyleContext context = new StyleContext(); StyledDocument document = new DefaultStyledDocument(context); Style labelStyle = context.getStyle(StyleContext.DEFAULT_STYLE); Icon icon = new ImageIcon("yourFile.gif"); JLabel label = new JLabel(icon); StyleConstants.setComponent(labelStyle, label); try {/*from ww w .ja v a 2 s . c o m*/ document.insertString(document.getLength(), "Ignored", labelStyle); } catch (BadLocationException badLocationException) { System.err.println("Oops"); } JTextPane textPane = new JTextPane(document); textPane.setEditable(false); JScrollPane scrollPane = new JScrollPane(textPane); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:SpecificCellWithDifferentWidthPDF.java
public static void main(String[] args) { Document document = new Document(); try {// w w w. jav a 2 s . c o m PdfWriter.getInstance(document, new FileOutputStream("SpecificCellWithDifferentWidthPDF.pdf")); document.open(); Table aTable; aTable = new Table(4, 4); // 4 rows, 4 columns aTable.setWidths(new float[] { 2f, 1f, 1f, 1f }); aTable.setAlignment(Element.ALIGN_RIGHT); aTable.addCell("2.2", new Point(2, 2)); aTable.addCell("3.3", new Point(3, 3)); aTable.addCell("2.1", new Point(2, 1)); aTable.addCell("1.3", new Point(1, 3)); document.add(aTable); aTable.setConvert2pdfptable(true); document.add(aTable); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
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 w w w . j ava2 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 -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(); } }