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:RawDataFromImageFilePDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {//www.ja va 2 s . c o m
        PdfWriter.getInstance(document, new FileOutputStream("RawDataFromImageFilePDF.pdf"));
        document.open();

        RandomAccessFile rf = new RandomAccessFile("logo.png", "r");
        int size = (int) rf.length();
        byte imext[] = new byte[size];
        rf.readFully(imext);
        rf.close();

        Image img1 = Image.getInstance(imext);
        img1.setAbsolutePosition(50, 500);
        document.add(img1);

    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:MainClass.java

public static void main(String[] args) {
    int count = 100;

    long[] numbers = new long[count];

    for (int i = 0; i < numbers.length; i++) {
        numbers[i] = i;/*from  w  w  w  .  j av a2 s  .  c  o  m*/

    }
    File aFile = new File("data.bin");
    FileOutputStream outputFile = null;
    try {
        outputFile = new FileOutputStream(aFile);
    } catch (FileNotFoundException e) {
        e.printStackTrace(System.err);
        System.exit(1);
    }
    FileChannel file = outputFile.getChannel();
    final int BUFFERSIZE = 100;
    ByteBuffer buf = ByteBuffer.allocate(BUFFERSIZE);
    LongBuffer longBuf = buf.asLongBuffer();

    int numberWritten = 0;

    while (numberWritten < numbers.length) {
        longBuf.put(numbers, numberWritten, min(longBuf.capacity(), numbers.length - numberWritten));
        buf.limit(8 * longBuf.position());
        try {
            file.write(buf);
            numberWritten += longBuf.position();
        } catch (IOException e) {
            e.printStackTrace(System.err);
            System.exit(1);
        }
        longBuf.clear();
        buf.clear();
    }

    try {
        System.out.println("File written is " + file.size() + " bytes.");
        outputFile.close();
    } catch (IOException e) {
        e.printStackTrace(System.err);
        System.exit(1);
    }
}

From source file:TextBackgroundPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {// w  ww  . ja  v a2  s.  c o m
        PdfWriter.getInstance(document, new FileOutputStream("TextBackgroundPDF.pdf"));
        document.open();
        Chunk high = new Chunk("highlighted");
        high.setBackground(new Color(0xFF, 0x00, 0x00));
        Paragraph p = new Paragraph("The following chunk is ");
        p.add(high);
        document.add(p);
    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:MainClass.java

public static void main(String[] args) {
    ParserGetter kit = new ParserGetter();
    HTMLEditorKit.Parser parser = kit.getParser();
    HTMLEditorKit.ParserCallback callback = new ReportAttributes();

    try {/*  w w  w. ja  va2s.c  o  m*/
        URL u = new URL("http://www.java2s.com");
        InputStream in = u.openStream();
        InputStreamReader r = new InputStreamReader(in);
        parser.parse(r, callback, false);
    } catch (IOException e) {
        System.err.println(e);
    }
}

From source file:GrepReader.java

public static void main(String args[]) {
    try {//from   w ww  . ja  v  a  2 s  .c o m
        GrepReader in = new GrepReader(new FileReader("GrepReader.java"), "GrepReader");
        String line;
        while ((line = in.readLine()) != null)
            System.out.println(line);
        in.close();
    } catch (Exception e) {
        System.err.println(e);
    }
}

From source file:ConnectMethodExampleForProxyClient.java

public static void main(String args[]) {

    ProxyClient client = new ProxyClient();
    client.getParams().setParameter("http.useragent", "Proxy Test Client");

    client.getHostConfiguration().setHost("www.somehost.com");
    client.getHostConfiguration().setProxy("localproxyaddress", 80);

    Socket socket = null;/*from ww w  .  ja va 2  s .  c om*/

    try {
        ConnectResponse response = client.connect();
        socket = response.getSocket();
        if (socket == null) {
            ConnectMethod method = response.getConnectMethod();
            System.err.println("Socket not created: " + method.getStatusLine());
        }
        // do something
    } catch (Exception e) {
        System.err.println(e);
    } finally {
        if (socket != null)
            try {
                socket.close();
            } catch (Exception fe) {
            }
    }

}

From source file:Main.java

public static void main(String[] args) {

    Path newfile_2 = FileSystems.getDefault().getPath("/home/tutorial/Java/2010/demo.txt");

    //create a file with a set of specified attributes
    Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rw-------");
    FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms);
    try {//w  w w  . j  a  v a  2s.  c o m
        Files.createFile(newfile_2, attr);
    } catch (IOException e) {
        System.err.println(e);
    }

}

From source file:DrawArcPDF.java

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

        PdfContentByte cb = writer.getDirectContent();
        PdfTemplate template = cb.createTemplate(500, 200);
        template.setLineWidth(2f);
        template.arc(20f, 20f, 00f, -40f, 90f, 45f);
        template.stroke();
        template.setLineWidth(12f);

        cb.addTemplate(template, 0, 1, -1, 0, 500, 200);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:EndOfLineWithTextRenderModePDF.java

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

        document.open();

        Chunk chunk = new Chunk(
                "1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0");
        chunk.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_STROKE, 0.3f, new Color(30, 30, 30));
        document.add(chunk);

    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:lookForPorts3.java

public static void main(String[] args) {

    Socket theSocket;//from   w  w w  .j  a  va  2 s .  co m
    String host = "localhost";

    if (args.length > 0) {
        host = args[0];
    }

    try {
        InetAddress theAddress = InetAddress.getByName(host);
        for (int i = 1; i <= 65535; i++) {
            try {
                theSocket = new Socket(host, i);
                System.out.println("There is a server on port " + i + " of " + host);
                theSocket.close();
            } catch (IOException e) {
                // must not be a server on this port
            }
        }
    } catch (UnknownHostException e) {
        System.err.println(e);
    }

}