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

public static void main(String argv[]) throws IOException {

    // A Runtime object has methods for dealing with the OS
    Runtime r = Runtime.getRuntime();
    Process p; // Process tracks one external native process
    BufferedReader is; // reader for output of process
    String line;/*from w  w w  .  j  a v a  2s .  com*/

    // Our argv[0] contains the program to run; remaining elements
    // of argv contain args for the target program. This is just
    // what is needed for the String[] form of exec.
    p = r.exec(argv);

    System.out.println("In Main after exec");

    // getInputStream gives an Input stream connected to
    // the process p's standard output. Just use it to make
    // a BufferedReader to readLine() what the program writes out.
    is = new BufferedReader(new InputStreamReader(p.getInputStream()));

    while ((line = is.readLine()) != null)
        System.out.println(line);

    System.out.println("In Main after EOF");
    System.out.flush();
    try {
        p.waitFor(); // wait for process to complete
    } catch (InterruptedException e) {
        System.err.println(e); // "Can'tHappen"
        return;
    }
    System.err.println("Process done, exit status was " + p.exitValue());
    return;
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String url = "jdbc:odbc:technical_library";
    String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    String theStatement = "SELECT authid, lastname, firstname, email FROM authors ORDER BY authid";

    try {/*from  w  w  w .  j  a v a2s . co m*/
        Class.forName(driver);
        Connection connection = DriverManager.getConnection(url, "guest", "guest");
        Statement queryAuthors = connection.createStatement();
        ResultSet results = queryAuthors.executeQuery(theStatement);

        String lastname, firstname, email;
        int id;
        while (results.next()) {
            id = results.getInt(1);
            lastname = results.getString(2);
            firstname = results.getString(3);
            email = results.getString(4);

            if (results.wasNull()) {
                email = "no email";
            }
            System.out.println(Integer.toString(id) + ", " + lastname.trim() + ", " + firstname.trim() + ", "
                    + email.trim());
        }
        queryAuthors.close();
    } catch (Exception e) {
        System.err.println(e);
    }
}

From source file:JTextPaneStyle.java

public static void main(String args[]) {
    JFrame frame = new JFrame("TextPane Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    StyleContext context = new StyleContext();
    StyledDocument document = new DefaultStyledDocument(context);

    Style style = context.getStyle(StyleContext.DEFAULT_STYLE);
    StyleConstants.setAlignment(style, StyleConstants.ALIGN_RIGHT);
    StyleConstants.setFontSize(style, 14);
    StyleConstants.setSpaceAbove(style, 4);
    StyleConstants.setSpaceBelow(style, 4);

    try {/*from   w w  w.  j av  a  2s. co  m*/
        document.insertString(document.getLength(), message, style);
    } catch (BadLocationException badLocationException) {
        System.err.println("Oops");
    }

    JTextPane textPane = new JTextPane(document);
    textPane.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textPane);
    frame.add(scrollPane, BorderLayout.CENTER);

    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:DOMEdit.java

static public void main(String[] arg) {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setValidating(true);/* w  w  w .j ava2 s .  co m*/
    dbf.setNamespaceAware(true);
    dbf.setIgnoringElementContentWhitespace(true);

    Document doc = null;
    try {
        DocumentBuilder builder = dbf.newDocumentBuilder();
        builder.setErrorHandler(new MyErrorHandler());
        InputSource is = new InputSource("personWithDTD.xml");
        doc = builder.parse(is);

        findByID(doc, "B");

        write(doc);
    } catch (Exception e) {
        System.err.println(e);
    }
}

From source file:PdfPageEventHelperDemo.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from   w  w w.j ava2  s .c  om*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("PdfPageEventHelperDemo.pdf"));
        writer.setPageEvent(new PdfPageEventHelperDemo());
        document.open();

        Paragraph p = new Paragraph("Generic page event");
        document.add(p);

        Chunk box = new Chunk("text");
        box.setGenericTag("text");

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

From source file:TextFieldsPDF.java

License:asdf

public static void main(String[] args) {
    Document document = new Document(PageSize.A4.rotate());
    try {//from   w  w  w.j  ava 2s  . c o m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TextFieldsPDF.pdf"));
        document.open();

        TextField tf = new TextField(writer, new Rectangle(100, 300, 100 + 100, 300 + 50), "asdf");
        tf.setBackgroundColor(Color.WHITE);
        tf.setBorderColor(Color.BLACK);
        tf.setBorderWidth(1);
        tf.setBorderStyle(PdfBorderDictionary.STYLE_BEVELED);
        tf.setText("text...");
        tf.setAlignment(Element.ALIGN_CENTER);
        tf.setOptions(TextField.MULTILINE | TextField.REQUIRED);
        tf.setRotation(90);
        PdfFormField field = tf.getTextField();
        writer.addAnnotation(field);

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

From source file:base64test.Base64Test.java

/**
 * @param args the command line arguments
 *//*from www .  j av a2 s  . c  o m*/
public static void main(String[] args) {
    try {
        if (!Base64.isBase64(args[0])) {
            throw new Exception("Arg 1 is not a Base64 string!");
        } else {
            String decodedBase64String = new String(Base64.decodeBase64(args[0]));
            File tempFile = File.createTempFile("base64Test", ".tmp");
            tempFile.deleteOnExit();
            FileWriter fw = new FileWriter(tempFile, false);
            PrintWriter pw = new PrintWriter(fw);
            pw.write(decodedBase64String);
            pw.close();
            String fileType = getFileType(tempFile.toPath());
            System.out.println(fileType);
            System.in.read();
        }
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
}

From source file:MappingContentHandler.java

static public void main(String[] arg) {
    try {//w w  w .  j a  v a  2 s  .  c om
        SAXParserFactory spf = SAXParserFactory.newInstance();
        SAXParser parser = spf.newSAXParser();
        XMLReader reader = parser.getXMLReader();
        reader.setErrorHandler(new MyErrorHandler());
        MyTextHandler duper = new MyTextHandler();
        reader.setContentHandler(duper);
        InputSource is = new InputSource("person.xml");
        reader.parse(is);
    } catch (SAXException e) {
        System.out.println(e);
    } catch (ParserConfigurationException e) {
        System.err.println(e);
        System.exit(1);
    } catch (IOException e) {
        System.err.println(e);
        System.exit(1);
    }
}

From source file:BeanUtilsExampleV2.java

  public static void main(String args[]) throws Exception {
    BeanUtilsExampleV2 diff = new BeanUtilsExampleV2();
    Movie movieBean = diff.prepareData();

    // create a new Movie with the same properties
    Movie newMovieBean = new Movie();
    BeanUtils.copyProperties(newMovieBean, movieBean);
    // Movie newMovieBean = (Movie)BeanUtils.cloneBean(movieBean);

    // change its title
    BeanUtils.setProperty(newMovieBean, "title", "Quills");

    // and date/*from  ww w . j av a  2  s. c o m*/
    BeanUtils.setProperty(
       newMovieBean,
       "dateOfRelease",
       new GregorianCalendar(2000, 0, 1).getTime());

    // and director name
    BeanUtils.setProperty(newMovieBean, "director.name", "Philip Kaufman");

    // and director's home number
    BeanUtils.setProperty(
       newMovieBean,
       "director.contactNumber(Home)",
       "3349084333");

    System.err.println(BeanUtils.getProperty(movieBean, "title"));
    System.err.println(BeanUtils.getProperty(movieBean, "director.name"));
    System.err.println(BeanUtils.getProperty(
       newMovieBean,
       "director.contactNumber(Home)"));
}