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

public static void main(String[] args) {
    Document.compress = false;/*w  ww. ja v  a2s  .com*/
    Document document = new Document();
    try {
        PdfWriter.getInstance(document, new FileOutputStream("TableCellWithBackgroundPDF.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:FormListPDF.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4);
    try {/*from www . j  a  v  a 2s .  co m*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("FormListPDF.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        cb.moveTo(0, 0);
        String options[] = { "A", "B", "C" };
        PdfFormField field = PdfFormField.createList(writer, options, 0);
        field.setWidget(new Rectangle(100, 700, 180, 760), PdfAnnotation.HIGHLIGHT_OUTLINE);
        field.setFieldName("AList");
        field.setValueAsString("B");
        writer.addAnnotation(field);

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

From source file:MainClass.java

public static void main(String args[]) {
    Connection conn = null;//from  ww w  . j  a  v a2s. co  m
    Statement stmt = null;
    ResultSet rs = null;
    try {
        conn = getConnection();
        stmt = conn.createStatement();
        String query = "select EmployeeID, LastName, FirstName from Employees";
        rs = stmt.executeQuery(query);
        while (rs.next()) {
            System.out.println(rs.getString("EmployeeID") + " " + rs.getString("LastName") + " "
                    + rs.getString("FirstName"));
        }
    } catch (Exception e) {
        // handle the exception
        e.printStackTrace();
        System.err.println(e.getMessage());
    } finally {
        try {
            rs.close();
            stmt.close();
            conn.close();
        } catch (Exception ee) {
            ee.printStackTrace();
        }
    }
}

From source file:httpscheduler.HttpScheduler.java

/**
 * @param args the command line arguments
 * @throws java.lang.Exception//from w  w  w. j  a  v a 2  s .  c  o  m
 */

public static void main(String[] args) throws Exception {

    if (args.length != 2) {
        System.err.println("Invalid command line parameters for worker");
        System.exit(-1);
    }

    int fixedExecutorSize = 4;

    //Creating fixed size executor
    ThreadPoolExecutor taskCommExecutor = new ThreadPoolExecutor(fixedExecutorSize, fixedExecutorSize, 0L,
            TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
    // Used for late binding
    JobMap jobMap = new JobMap();

    // Set port number
    int port = Integer.parseInt(args[0]);

    // Set worker mode
    String mode = args[1].substring(2);

    // Set up the HTTP protocol processor
    HttpProcessor httpproc = HttpProcessorBuilder.create().add(new ResponseDate())
            .add(new ResponseServer("Test/1.1")).add(new ResponseContent()).add(new ResponseConnControl())
            .build();

    // Set up request handlers
    UriHttpRequestHandlerMapper reqistry = new UriHttpRequestHandlerMapper();
    // Different handlers for late binding and generic cases
    if (mode.equals("late"))
        reqistry.register("*", new LateBindingRequestHandler(taskCommExecutor, jobMap));
    else
        reqistry.register("*", new GenericRequestHandler(taskCommExecutor, mode));

    // Set up the HTTP service
    HttpService httpService = new HttpService(httpproc, reqistry);

    SSLServerSocketFactory sf = null;

    // create a thread to listen for possible client available connections
    Thread t;
    if (mode.equals("late"))
        t = new LateBindingRequestListenerThread(port, httpService, sf);
    else
        t = new GenericRequestListenerThread(port, httpService, sf);
    System.out.println("Request Listener Thread created");
    t.setDaemon(false);
    t.start();

    // main thread should wait for the listener to exit before shutdown the
    // task executor pool
    t.join();

    // shutdown task executor pool and wait for any taskCommExecutor thread
    // still running
    taskCommExecutor.shutdown();
    while (!taskCommExecutor.isTerminated()) {
    }

    System.out.println("Finished all task communication executor threads");
    System.out.println("Finished all tasks");

}

From source file:ArrayEnumerationFactory.java

public static void main(String args[]) {
    Enumeration e = makeEnumeration(args);
    while (e.hasMoreElements()) {
        System.out.println(e.nextElement());
    }//from   ww  w  .j  a v a2  s  . c  o  m
    e = makeEnumeration(new int[] { 1, 3, 4, 5 });
    while (e.hasMoreElements()) {
        System.out.println(e.nextElement());
    }
    try {
        e = makeEnumeration(new Double(Math.PI));
    } catch (IllegalArgumentException ex) {
        System.err.println("Can't enumerate that: " + ex.getMessage());
    }
}

From source file:examples.CheckSessionState.java

public static void main(String[] args) {
    if (args.length == 0) {
        System.err.println("At least one path to serialized session required.");
        System.exit(1);/*  ww w. j  a  va 2 s  .c om*/
    }
    for (String sessionStatePath : args) {
        try {
            File sessionStateFile = new File(sessionStatePath);
            SessionState sessionState = JACKSON.readValue(sessionStateFile, SessionState.class);
            final AtomicInteger idx = new AtomicInteger(0);
            sessionState.foreachPartition(new Action1<PartitionState>() {
                @Override
                public void call(PartitionState state) {
                    int partition = idx.getAndIncrement();
                    if (lessThan(state.getEndSeqno(), state.getStartSeqno())) {
                        System.out.printf("stream request for partition %d will fail because "
                                + "start sequence number (%d) is larger than " + "end sequence number (%d)\n",
                                partition, state.getStartSeqno(), state.getEndSeqno());
                    }
                    if (lessThan(state.getStartSeqno(), state.getSnapshotStartSeqno())) {
                        System.out.printf(
                                "stream request for partition %d will fail because "
                                        + "snapshot start sequence number (%d) must not be larger than "
                                        + "start sequence number (%d)\n",
                                partition, state.getSnapshotStartSeqno(), state.getStartSeqno());
                    }
                    if (lessThan(state.getSnapshotEndSeqno(), state.getStartSeqno())) {
                        System.out.printf(
                                "stream request for partition %d will fail because "
                                        + "start sequence number (%d) must not be larger than "
                                        + "snapshot end sequence number (%d)\n",
                                partition, state.getStartSeqno(), state.getSnapshotEndSeqno());
                    }
                }
            });
        } catch (IOException e) {
            System.out.println("Failed to decode " + sessionStatePath + ": " + e);
        }
    }
}

From source file:io.s4.util.AvroSchemaSupplementer.java

public static void main(String args[]) {
    if (args.length < 1) {
        System.err.println("No schema filename specified");
        System.exit(1);//from ww w.  j av a  2  s . c o m
    }

    String filename = args[0];
    FileReader fr = null;
    BufferedReader br = null;
    InputStreamReader isr = null;
    try {
        if (filename == "-") {
            isr = new InputStreamReader(System.in);
            br = new BufferedReader(isr);
        } else {
            fr = new FileReader(filename);
            br = new BufferedReader(fr);
        }

        String inputLine = "";
        StringBuffer jsonBuffer = new StringBuffer();
        while ((inputLine = br.readLine()) != null) {
            jsonBuffer.append(inputLine);
        }

        JSONObject jsonRecord = new JSONObject(jsonBuffer.toString());

        JSONObject keyPathElementSchema = new JSONObject();
        keyPathElementSchema.put("name", "KeyPathElement");
        keyPathElementSchema.put("type", "record");

        JSONArray fieldsArray = new JSONArray();
        JSONObject fieldRecord = new JSONObject();
        fieldRecord.put("name", "index");
        JSONArray typeArray = new JSONArray("[\"int\", \"null\"]");
        fieldRecord.put("type", typeArray);
        fieldsArray.put(fieldRecord);
        fieldRecord = new JSONObject();
        fieldRecord.put("name", "keyName");
        typeArray = new JSONArray("[\"string\", \"null\"]");
        fieldRecord.put("type", typeArray);
        fieldsArray.put(fieldRecord);

        keyPathElementSchema.put("fields", fieldsArray);

        JSONObject keyInfoSchema = new JSONObject();
        keyInfoSchema.put("name", "KeyInfo");
        keyInfoSchema.put("type", "record");

        fieldsArray = new JSONArray();
        fieldRecord = new JSONObject();
        fieldRecord.put("name", "keyPath");
        typeArray = new JSONArray("[\"string\", \"null\"]");
        fieldRecord.put("type", typeArray);
        fieldsArray.put(fieldRecord);
        fieldRecord = new JSONObject();
        fieldRecord.put("name", "fullKeyPath");
        typeArray = new JSONArray("[\"string\", \"null\"]");
        fieldRecord.put("type", typeArray);
        fieldsArray.put(fieldRecord);
        fieldRecord = new JSONObject();
        fieldRecord.put("name", "keyPathElementList");
        JSONObject typeRecord = new JSONObject();
        typeRecord.put("type", "array");
        typeRecord.put("items", keyPathElementSchema);
        fieldRecord.put("type", typeRecord);
        fieldsArray.put(fieldRecord);

        keyInfoSchema.put("fields", fieldsArray);

        JSONObject partitionInfoSchema = new JSONObject();
        partitionInfoSchema.put("name", "PartitionInfo");
        partitionInfoSchema.put("type", "record");
        fieldsArray = new JSONArray();
        fieldRecord = new JSONObject();
        fieldRecord.put("name", "partitionId");
        typeArray = new JSONArray("[\"int\", \"null\"]");
        fieldRecord.put("type", typeArray);
        fieldsArray.put(fieldRecord);
        fieldRecord = new JSONObject();
        fieldRecord.put("name", "compoundKey");
        typeArray = new JSONArray("[\"string\", \"null\"]");
        fieldRecord.put("type", typeArray);
        fieldsArray.put(fieldRecord);
        fieldRecord = new JSONObject();
        fieldRecord.put("name", "compoundValue");
        typeArray = new JSONArray("[\"string\", \"null\"]");
        fieldRecord.put("type", typeArray);
        fieldsArray.put(fieldRecord);
        fieldRecord = new JSONObject();
        fieldRecord.put("name", "keyInfoList");
        typeRecord = new JSONObject();
        typeRecord.put("type", "array");
        typeRecord.put("items", keyInfoSchema);
        fieldRecord.put("type", typeRecord);
        fieldsArray.put(fieldRecord);

        partitionInfoSchema.put("fields", fieldsArray);

        fieldRecord = new JSONObject();
        fieldRecord.put("name", "S4__PartitionInfo");
        typeRecord = new JSONObject();
        typeRecord.put("type", "array");
        typeRecord.put("items", partitionInfoSchema);
        fieldRecord.put("type", typeRecord);

        fieldsArray = jsonRecord.getJSONArray("fields");
        fieldsArray.put(fieldRecord);

        System.out.println(jsonRecord.toString(3));
    } catch (Exception ioe) {
        throw new RuntimeException(ioe);
    } finally {
        if (br != null)
            try {
                br.close();
            } catch (Exception e) {
            }
        if (isr != null)
            try {
                isr.close();
            } catch (Exception e) {
            }
        if (fr != null)
            try {
                fr.close();
            } catch (Exception e) {
            }
    }
}

From source file:AHrefForAWebsitePDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from  www. j  a va  2  s .c  om
        PdfWriter.getInstance(document, new FileOutputStream("AHrefForAWebsitePDF.pdf"));
        HtmlWriter.getInstance(document, new FileOutputStream("AHrefForAWebsite.html"));

        document.open();

        Paragraph paragraph = new Paragraph("Please visit my ");
        Anchor anchor1 = new Anchor("website (external reference)",
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE, new Color(0, 0, 255)));
        anchor1.setReference("http://www.java2s.com");
        paragraph.add(anchor1);

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

From source file:CustomPDFDocumentPageSizePDF.java

public static void main(String[] args) {
    Rectangle pageSize = new Rectangle(216, 720);
    Document document = new Document(pageSize);

    try {/* w  w w  .ja  v a  2s. c  o  m*/
        PdfWriter.getInstance(document, new FileOutputStream("CustomPDFDocumentPageSizePDF.pdf"));
        document.open();
        document.add(new Paragraph("The size of this page is 216x720 points."));
        document.add(new Paragraph("216pt / 72 points per inch = 3 inch"));
        document.add(new Paragraph("720pt / 72 points per inch = 10 inch"));
        document.add(new Paragraph("The size of this page is 3x10 inch."));
        document.add(new Paragraph("3 inch x 2.54 = 7.62 cm"));
        document.add(new Paragraph("10 inch x 2.54 = 25.4 cm"));
        document.add(new Paragraph("The size of this page is 7.62x25.4 cm."));

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

From source file:TableCellSpanPDF.java

public static void main(String[] args) {
    Document document = new Document();

    try {//from   w  w w.j a  va 2 s  .co m
        PdfWriter.getInstance(document, new FileOutputStream("TableCellSpanPDF.pdf"));
        document.open();

        PdfPTable table = new PdfPTable(3);
        PdfPCell cell = new PdfPCell(new Paragraph("header with colspan 3"));
        cell.setColspan(3);
        table.addCell(cell);
        table.addCell("1.1");
        table.addCell("2.1");
        table.addCell("3.1");
        table.addCell("1.2");
        table.addCell("2.2");
        table.addCell("3.2");

        cell = new PdfPCell(new Paragraph("cell test1"));
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph("cell test2"));
        cell.setColspan(2);
        table.addCell(cell);

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