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

public static void main(String[] a) {
    File aFile = new File("C:/myFile.text");
    FileOutputStream outputFile = null; // Place to store an output stream
                                        // reference
    try {/*from   ww  w .  j a  v  a 2  s  .c o m*/
        // Create the stream opened to write
        outputFile = new FileOutputStream(aFile);
    } catch (FileNotFoundException e) {
        e.printStackTrace(System.err);
        System.exit(1);
    }
    // Get the channel for the file
    FileChannel outputChannel = outputFile.getChannel();
}

From source file:HelloWorldPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from  w w w  .  j ava  2 s.co  m
        PdfWriter.getInstance(document, new FileOutputStream("HelloWorldPDF.pdf"));
        document.open();
        document.add(new Paragraph("Hello World"));
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:EndOfLinePDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from   w  w  w . jav a2  s. com*/
        PdfWriter.getInstance(document, new FileOutputStream("EndOfLinePDF.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");
        document.add(chunk);

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

From source file:MainClass.java

public static void main(String[] args) {
    File aFile = new File("afile.txt");
    FileOutputStream outputFile = null;
    try {// ww w. j a v a2  s  .  c om
        outputFile = new FileOutputStream(aFile, true);
        System.out.println("File stream created successfully.");
    } catch (FileNotFoundException e) {
        e.printStackTrace(System.err);
    }
    ByteBuffer buf = ByteBuffer.allocate(1024);
    System.out.println("\nByte buffer:");
    System.out.printf("position = %2d  Limit = %4d  capacity = %4d%n", buf.position(), buf.limit(),
            buf.capacity());

    // Create a view buffer
    CharBuffer charBuf = buf.asCharBuffer();
    System.out.println("Char view buffer:");
    System.out.printf("position = %2d  Limit = %4d  capacity = %4d%n", charBuf.position(), charBuf.limit(),
            charBuf.capacity());
    try {
        outputFile.close(); // Close the O/P stream & the channel
    } catch (IOException e) {
        e.printStackTrace(System.err);
    }
}

From source file:ImageScalingByPercentPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {// ww  w . j  ava  2  s .  c om
        PdfWriter.getInstance(document, new FileOutputStream("ImageScalingByPercentPDF.pdf"));
        document.open();
        Image png = Image.getInstance("logo.png");
        png.scalePercent(50);

        document.add(png);

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

From source file:PdfVersion1_2.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from  w w w.jav  a  2s  . c o  m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("PDFversion1_2.pdf"));
        writer.setPdfVersion(PdfWriter.VERSION_1_2);
        document.open();
        document.add(new Paragraph("This is a PDF-1.2 document"));
    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:ClosingAPDFDocument.java

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

        document.add(new Paragraph("some text"));
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:com.dobri.springldap.NewMain.java

public static void main(String[] args) {
    try {//  w  w  w  . ja  v a  2 s . co  m
        ApplicationContext ac = new ClassPathXmlApplicationContext("config.xml");
    } catch (Exception ioe) {
        System.err.println("nema config fajla !");
    }

}

From source file:MainClass.java

public static void main(String[] args) {

    String phrase = new String("www.java2s.com API \n");
    File aFile = new File("test.txt");

    FileOutputStream file = null;
    try {//  w  w w . ja  v a 2s  .co  m
        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:Diff.java

public static void main(String args[]) {
    RandomAccessFile fh1 = null;/*from  ww  w  . j a v a  2s. c om*/
    RandomAccessFile fh2 = null;
    int bufsize; // size of smallest file
    long filesize1 = -1;
    long filesize2 = -1;
    byte buffer1[]; // the two file caches
    byte buffer2[];
    // check what you get as command-line arguments
    if (args.length == 0 || args[0].equals("?")) {
        System.err.println("USAGE: java Diff <file1> <file2> | ?");
        System.exit(0);
    }
    // open file ONE for reading
    try {
        fh1 = new RandomAccessFile(args[0], "r");
        filesize1 = fh1.length();
    } catch (IOException ioErr) {
        System.err.println("Could not find " + args[0]);
        System.err.println(ioErr);
        System.exit(100);
    }
    // open file TWO for reading
    try {
        fh2 = new RandomAccessFile(args[1], "r");
        filesize2 = fh2.length();
    } catch (IOException ioErr) {
        System.err.println("Could not find " + args[1]);
        System.err.println(ioErr);
        System.exit(100);
    }
    if (filesize1 != filesize2) {
        System.out.println("Files differ in size !");
        System.out.println("'" + args[0] + "' is " + filesize1 + " bytes");
        System.out.println("'" + args[1] + "' is " + filesize2 + " bytes");
    }
    // allocate two buffers large enough to hold entire files
    bufsize = (int) Math.min(filesize1, filesize2);
    buffer1 = new byte[bufsize];
    buffer2 = new byte[bufsize];
    try {
        fh1.readFully(buffer1, 0, bufsize);
        fh2.readFully(buffer2, 0, bufsize);

        for (int i = 0; i < bufsize; i++) {
            if (buffer1[i] != buffer2[i]) {
                System.out.println("Files differ at offset " + i);
                break;
            }
        }
    } catch (IOException ioErr) {
        System.err.println("ERROR: An exception occurred while processing the files");
        System.err.println(ioErr);
    } finally {
        try {
            fh1.close();
            fh2.close();
        } catch (IOException ignored) {
        }
    }
}