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

public static void main(String[] argv) {
    for (int i = 0; i < argv.length; i++)
        try {/*from w ww  .j a va 2 s. co m*/
            BigInteger l = new BigInteger(argv[i]);
            if (l.compareTo(BigInteger.ZERO) < 0) {
                System.err.println(argv[i] + " -> TOO SMALL");
                continue;
            }
            System.out.println(argv[i] + "->" + findPalindrome(l));
        } catch (NumberFormatException e) {
            System.err.println(argv[i] + "-> INVALID");
        } catch (IllegalStateException e) {
            System.err.println(argv[i] + "-> " + e);
        }
}

From source file:SettingPageBackgroundColorPDF.java

public static void main(String[] args) {
    Rectangle pageSize = new Rectangle(216, 720);
    pageSize.setBackgroundColor(new java.awt.Color(0xFF, 0xFF, 0xDE));
    Document document = new Document(pageSize);

    try {/*from   ww  w.j av a  2s. c om*/
        PdfWriter.getInstance(document, new FileOutputStream("SettingPageBackgroundColorPDF.pdf"));
        document.open();
        document.add(new Paragraph("Text"));

    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:PdfEvents.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4, 80, 50, 30, 65);
    try {//w w  w.  j a  v  a2  s . c o  m

        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("PdfEvents.pdf"));
        document.open();
        writer.setPageEvent(new MyPageEvents());
        document.newPage();
        document.add(new Paragraph("Text"));
        document.close();
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
}

From source file:Main.java

public static void main(String[] args) {
    int[] x = new int[] { 1, 2, 3 };
    int[] y = new int[] { 4, 5, 6 };
    Polygon polygon = new Polygon(x, y, x.length);
    try {//from   w w w.ja v a2s  . c  om
        ObjectOutputStream objectOut = new ObjectOutputStream(
                new BufferedOutputStream(new FileOutputStream("Polygons.bin")));
        objectOut.writeObject(polygon);
        objectOut.close();
    } catch (IOException e) {
        e.printStackTrace(System.err);
    }
    try {
        ObjectInputStream objectIn = new ObjectInputStream(
                new BufferedInputStream(new FileInputStream("Polygons.bin")));
        Polygon theLine = (Polygon) objectIn.readObject();
        System.out.println(theLine);
        objectIn.close();
    } catch (Exception e) {
        e.printStackTrace(System.err);
    }
}

From source file:StrictImageSequencePDF.java

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

        document.open();

        Image image = Image.getInstance("logo.png");
        for (int i = 0; i < 20; i++) {
            document.add(image);
        }

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

From source file:Main.java

public static void main(String[] args) throws Exception {
    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine engine = manager.getEngineByName("JavaScript");

    if (!(engine instanceof Invocable)) {
        System.out.println("Interface implementation in script" + "is not supported.");
        return;/*  w w  w  .  ja v  a2 s  . co  m*/
    }
    Invocable inv = (Invocable) engine;
    String scriptPath = "c:/Java_Dev/cal.js";
    engine.eval("load('" + scriptPath + "')");
    Calculator calc = inv.getInterface(Calculator.class);
    if (calc == null) {
        System.err.println("Calculator interface " + "implementation not found.");
        return;
    }
    double x = 2.0;
    double y = 1.0;
    double addResult = calc.add(x, y);

    System.out.println(addResult);
}

From source file:MainClass.java

public static void main(String[] args) {
    String[] phrases = { "A", "B 1", "C 1.3" };
    String dirname = "C:/test";
    String filename = "Phrases.txt";
    File dir = new File(dirname);
    File aFile = new File(dir, filename);
    FileOutputStream outputFile = null;
    try {/*from w  w w  .  jav  a 2s . c  om*/
        outputFile = new FileOutputStream(aFile, true);
    } catch (FileNotFoundException e) {
        e.printStackTrace(System.err);
    }
    FileChannel outChannel = outputFile.getChannel();
    ByteBuffer buf = ByteBuffer.allocate(1024);
    System.out.println(buf.position());
    System.out.println(buf.limit());
    System.out.println(buf.capacity());
    CharBuffer charBuf = buf.asCharBuffer();
    System.out.println(charBuf.position());
    System.out.println(charBuf.limit());
    System.out.println(charBuf.capacity());
    Formatter formatter = new Formatter(charBuf);
    int number = 0;
    for (String phrase : phrases) {
        formatter.format("%n %s", ++number, phrase);
        System.out.println(charBuf.position());
        System.out.println(charBuf.limit());
        System.out.println(charBuf.capacity());
        charBuf.flip();
        System.out.println(charBuf.position());
        System.out.println(charBuf.limit());
        System.out.println(charBuf.length());
        buf.limit(2 * charBuf.length()); // Set byte buffer limit
        System.out.println(buf.position());
        System.out.println(buf.limit());
        System.out.println(buf.remaining());
        try {
            outChannel.write(buf);
            buf.clear();
            charBuf.clear();
        } catch (IOException e) {
            e.printStackTrace(System.err);
        }
    }
    try {
        outputFile.close();
    } catch (IOException e) {
        e.printStackTrace(System.err);
    }
}

From source file:PlanetPrefs.java

public static void main(String args[]) {
    String names[] = { "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto" };
    int moons[] = { 0, 0, 1, 2, 16, 18, 21, 8, 1 };

    Preferences prefs = Preferences.userRoot().node("/MasteringJava/Chap17");

    for (int i = 0, n = names.length; i < n; i++) {
        prefs.putInt(names[i], moons[i]);
    }/*ww  w  . j a v  a  2  s.  com*/

    try {
        String keys[] = prefs.keys();
        for (int i = 0, n = keys.length; i < n; i++) {
            System.out.println(keys[i] + ": " + prefs.getInt(keys[i], 0));
        }
    } catch (BackingStoreException e) {
        System.err.println("Unable to read backing store: " + e);
    }
}

From source file:FormSignaturePDF.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4);
    try {//from w w w.j a v a 2  s.c o  m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("FormSignaturePDF.pdf"));
        document.open();
        PdfAcroForm acroForm = writer.getAcroForm();
        document.add(new Paragraph("Hello World"));
        acroForm.addSignature("sig", 73, 705, 149, 759);

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

From source file:TableColumnRowCountPDF.java

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

        Table table = new Table(2, 2); // 2 rows, 2 columns
        table.addCell("0.0");
        table.addCell("0.1");
        table.addCell("1.0");
        table.addCell("1.1");
        document.add(table);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}