Example usage for java.lang System err

List of usage examples for java.lang System err

Introduction

In this page you can find the example usage for java.lang System err.

Prototype

PrintStream err

To view the source code for java.lang System err.

Click Source Link

Document

The "standard" error output stream.

Usage

From source file:ImagesWMFPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from w  ww .  j  a v  a2s.  c o  m*/
        PdfWriter.getInstance(document, new FileOutputStream("ImagesWMFPDF.pdf"));
        document.open();

        document.add(new Paragraph("load a WMF image file"));
        Image img = Image.getInstance("logo.WMF");
        document.add(img);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:ImagesPNGPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*ww w .  ja  va 2 s  . c  om*/
        PdfWriter.getInstance(document, new FileOutputStream("ImagesPNGPDF.pdf"));
        document.open();

        document.add(new Paragraph("load a png image file"));
        Image img = Image.getInstance("logo.png");
        document.add(img);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:ImagesJPGPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from   ww  w .ja  v  a 2 s . c  o m*/
        PdfWriter.getInstance(document, new FileOutputStream("ImagesJPGPDF.pdf"));
        document.open();

        document.add(new Paragraph("load a jpg image file"));
        Image jpg = Image.getInstance("logo.jpg");
        document.add(jpg);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:MainClass.java

public static void main(String[] args) {

    try {/*from  w w  w.j a  v a 2s  .  c  o  m*/
        URL u = new URL("http://www.java2s.com");
        OutputStream out = new FileOutputStream("test.htm");
        InputStream in = u.openStream();
        DTD html = DTD.getDTD("html");
        System.out.println(html.getName());
        in.close();
        out.flush();
        out.close();
    } catch (Exception e) {
        System.err.println("Usage: java PageSaver url local_file");
    }

}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream("ttf.pdf"));
    document.open();//  ww w . j  a  va 2  s.  c om
    BaseFont bf = BaseFont.createFont("c:/windows/fonts/ARBLI___.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);
    Font font = new Font(bf, 12);
    System.err.println(bf.getClass().getName());
    document.add(new Paragraph("This is font arial black italic (embedded)", font));
    bf = BaseFont.createFont("c:/windows/fonts/ARBLI___.ttf", BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
    font = new Font(bf, 12);
    document.add(new Paragraph("This is font arial black italic (not embedded)", font));
    System.out.println("PostScript name:" + bf.getPostscriptFontName());

    String[] encoding = bf.getCodePagesSupported();
    for (int i = 0; i < encoding.length; i++) {
        System.out.println("encoding[" + i + "] = " + encoding[i]);
    }
    document.newPage();
    String[][] name = bf.getFullFontName();
    for (int i = 0; i < name.length; i++) {
        System.out.println(name[i][3] + " (" + name[i][0] + "; " + name[i][1] + "; " + name[i][2] + ")");
    }
    document.close();
}

From source file:NumFormatParse.java

/** The main (and only) method in this class. */
public static void main(String[] av) {

    //+//from w  w w  .j  ava2s.  c o m
    NumberFormat defForm = NumberFormat.getInstance();

    try {
        Number d = defForm.parse(input);
        System.out.println(input + " parses as " + d + " and formats as " + defForm.format(d));
    } catch (ParseException pe) {
        System.err.println(input + "not parseable!");
    }
    //-
}

From source file:MainClass.java

public static void main(String[] args) {
    try {/*from  w ww.j av  a  2  s.  c  o m*/
        URLConnection uc = new URL("http://www.demo2s.com").openConnection();
        System.out
                .println("Will retrieve file if it's been modified since " + new Date(uc.getIfModifiedSince()));
        uc.setIfModifiedSince(System.currentTimeMillis());
        System.out
                .println("Will retrieve file if it's been modified since " + new Date(uc.getIfModifiedSince()));
    } catch (Exception e) {
        System.err.println(e);
    }
}

From source file:MainClass.java

public static void main(String[] args) {

    String host = "localhost";

    try {//from  w ww  . j  av a2 s. c  o  m
        InetAddress theAddress = InetAddress.getByName(host);
        for (int i = 1; i < 65536; i++) {
            Socket connection = null;
            connection = new Socket(host, i);
            System.out.println("There is a server on port " + i + " of " + host);
            if (connection != null)
                connection.close();
        } // end for
    } catch (Exception ex) {
        System.err.println(ex);
    }

}

From source file:MainClass.java

public static void main(String args[]) {
    SynthLookAndFeel synth = new SynthLookAndFeel();
    try {//  w w  w. j a va2 s  . c  o m
        Class aClass = MainClass.class;
        InputStream is = aClass.getResourceAsStream("config.xml");
        if (is == null) {
            System.err.println("Unable to find theme configuration");
            System.exit(-1);
        }
        synth.load(is, aClass);
    } catch (ParseException e) {
        System.err.println("Unable to load theme configuration");
        System.exit(-2);
    }
    try {
        UIManager.setLookAndFeel(synth);
    } catch (javax.swing.UnsupportedLookAndFeelException e) {
        System.err.println("Unable to change look and feel");
        System.exit(-3);
    }
    JFrame frame = new JFrame("Synth Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton button = new JButton("Hello, Synth");
    frame.add(button, BorderLayout.CENTER);
    JTextField textField = new JTextField();
    frame.add(textField, BorderLayout.SOUTH);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] args) {
    File aFile = new File("data.dat");
    FileInputStream inFile = null;

    try {/*from   w w  w  .j  a  v  a  2  s  . c o  m*/
        inFile = new FileInputStream(aFile);
    } catch (FileNotFoundException e) {
        e.printStackTrace(System.err);
        System.exit(1);
    }

    FileChannel inChannel = inFile.getChannel();
    final int COUNT = 6;
    ByteBuffer buf = ByteBuffer.allocate(8 * COUNT);
    long[] data = new long[COUNT];
    try {
        int pos = 0;
        while (inChannel.read(buf) != -1) {
            try {
                ((ByteBuffer) (buf.flip())).asLongBuffer().get(data);
                pos = data.length;
            } catch (BufferUnderflowException e) {
                LongBuffer longBuf = buf.asLongBuffer();
                pos = longBuf.remaining();
                longBuf.get(data, 0, pos);
            }
            System.out.println();
            for (int i = 0; i < pos; i++) {
                System.out.printf("%10d", data[i]);
            }
            buf.clear();
        }
        System.out.println("\nEOF reached.");
        inFile.close();
    } catch (IOException e) {
        e.printStackTrace(System.err);
        System.exit(1);
    }
}