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

public static void main(String[] args) {
    Rectangle pageSize = new Rectangle(720, 720);
    /*//from  ww w  . jav  a  2s.  c om
     * The size of this page is 720x720 points. 720pt / 72 points per inch = 10 inch.
     * The size of this page is 10x10 inch." (25.4 cm by 25.4 cm) since
     * 10 inch x 2.54 = 25.4 cm" 
     */

    Document document = new Document(pageSize, 36, 18, 72, 72);
    /* The left border is 36pt or 0.5 inch or 1.27 cm"
    right border is 18pt or 0.25 inch or 0.63 cm."
    top border is 72pt or 1 inch or 2.54 cm.
    bottom border 72pt or 1 inch or 2.54 cm. 
     */
    try {
        PdfWriter.getInstance(document, new FileOutputStream("MeasurementsPDF.pdf"));
        document.open();
        document.add(new Paragraph("Measurements"));
    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:FormComboPDF.java

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

    try {//from  w  w w  . j a  v  a2 s.c  om
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("FormComboPDF.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        cb.moveTo(0, 0);
        String options[] = { "A", "B", "C" };
        PdfFormField field = PdfFormField.createCombo(writer, true, options, 0);
        field.setWidget(new Rectangle(100, 700, 180, 720), PdfAnnotation.HIGHLIGHT_INVERT);
        field.setFieldName("ACombo");
        field.setValueAsString("B");
        writer.addAnnotation(field);

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

From source file:com.jeffy.hdfs.HDFSWriteFile.java

/**
 * ??hdfs//  w  ww  .  ja  v a  2 s  .  com
 * 
 * @param args
 */
public static void main(String[] args) {
    if (args.length < 2) {
        System.err.println("Please input two parameter!");
        System.out.println("Parameter: localfile hdfsfile");
        System.exit(1);
    }

    String localPath = args[0];
    String hdfsPath = args[1];
    //??
    Configuration config = new Configuration();
    //??
    try (InputStream in = new BufferedInputStream(new FileInputStream(localPath))) {
        FileSystem fs = FileSystem.get(URI.create(hdfsPath), config);
        try (FSDataOutputStream out = fs.create(new Path(hdfsPath), new Progressable() {
            @Override
            public void progress() {
                System.out.println(".");
            }
        })) {
            //??OutputStream,Hadooporg.apache.commons.io.IOUtils
            IOUtils.copy(in, out);
            System.out.println("File copy finished.");
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:GetToKnowBindingsAndScopes.java

public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();
    manager.put("global", "global bindings");

    dumpBindings(manager.getBindings());
    ScriptEngine engine = manager.getEngineByExtension("js");
    engine.put("engine", "engine bindings");

    dumpBindings(engine.getBindings(ScriptContext.GLOBAL_SCOPE));

    dumpBindings(engine.getBindings(ScriptContext.ENGINE_SCOPE));

    try {/*from w w w  .j  a  v a  2 s.c  o  m*/
        Bindings bindings = engine.createBindings();
        bindings.put("engine", "overridden engine bindings");
        bindings.put("app", new GetToKnowBindingsAndScopes());
        bindings.put("bindings", bindings);
        engine.eval("app.dumpBindings (bindings);", bindings);
    } catch (ScriptException se) {
        System.err.println(se.getMessage());
    }

    ScriptEngine engine2 = manager.getEngineByExtension("js");
    engine2.put("engine2", "engine2 bindings");

    dumpBindings(engine2.getBindings(ScriptContext.GLOBAL_SCOPE));
    dumpBindings(engine2.getBindings(ScriptContext.ENGINE_SCOPE));
    dumpBindings(engine.getBindings(ScriptContext.ENGINE_SCOPE));
}

From source file:UsingFontFactoryPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {//  w ww . jav  a2s.c o  m
        PdfWriter.getInstance(document, new FileOutputStream("UsingFontFactoryPDF.pdf"));
        document.open();

        Paragraph p = new Paragraph("Font Families", FontFactory.getFont(FontFactory.HELVETICA, 16f));
        document.add(p);
        FontFactory.registerDirectories();
        TreeSet families = new TreeSet(FontFactory.getRegisteredFamilies());

        for (Iterator i = families.iterator(); i.hasNext();) {
            p = new Paragraph((String) i.next());
            document.add(p);
        }
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }

    document.close();
}

From source file:Main.java

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

    Path path = Paths.get("c:/home/tutorial/Java/JavaFX/Topic.txt");
    Path new_path = Paths.get("/home/tutorial/Java/JavaFX/new_Topic.txt");
    PosixFileAttributes attr = Files.readAttributes(path, PosixFileAttributes.class);
    attr = Files.getFileAttributeView(path, PosixFileAttributeView.class).readAttributes();

    //use of asFileAttribute
    FileAttribute<Set<PosixFilePermission>> posixattrs = PosixFilePermissions
            .asFileAttribute(attr.permissions());
    try {//from   www.j a  v  a 2 s .co m
        Files.createFile(new_path, posixattrs);
    } catch (IOException e) {
        System.err.println(e);
    }
}

From source file:GetMethodExample.java

public static void main(String args[]) {

    HttpClient client = new HttpClient();
    client.getParams().setParameter("http.useragent", "Test Client");
    client.getParams().setParameter("http.connection.timeout", new Integer(5000));

    GetMethod method = new GetMethod();
    FileOutputStream fos = null;/*w w w  .j  a va2s.c  o m*/

    try {

        method.setURI(new URI("http://www.google.com", true));
        int returnCode = client.executeMethod(method);

        if (returnCode != HttpStatus.SC_OK) {
            System.err.println("Unable to fetch default page, status code: " + returnCode);
        }

        System.err.println(method.getResponseBodyAsString());

        method.setURI(new URI("http://www.google.com/images/logo.gif", true));
        returnCode = client.executeMethod(method);

        if (returnCode != HttpStatus.SC_OK) {
            System.err.println("Unable to fetch image, status code: " + returnCode);
        }

        byte[] imageData = method.getResponseBody();
        fos = new FileOutputStream(new File("google.gif"));
        fos.write(imageData);

        HostConfiguration hostConfig = new HostConfiguration();
        hostConfig.setHost("www.yahoo.com", null, 80, Protocol.getProtocol("http"));

        method.setURI(new URI("/", true));

        client.executeMethod(hostConfig, method);

        System.err.println(method.getResponseBodyAsString());

    } catch (HttpException he) {
        System.err.println(he);
    } catch (IOException ie) {
        System.err.println(ie);
    } finally {
        method.releaseConnection();
        if (fos != null)
            try {
                fos.close();
            } catch (Exception fe) {
            }
    }

}

From source file:MaskInputSample.java

public static void main(String args[]) {

    JFrame frame = new JFrame("Mask Input");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel label;// www  .j  a va  2s. c o m
    JFormattedTextField input;
    JPanel panel;
    MaskFormatter formatter;

    BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS);
    frame.setLayout(layout);

    try {
        label = new JLabel("SSN");
        formatter = new MaskFormatter("###'-##'-####");
        input = new JFormattedTextField(formatter);
        input.setValue("123-45-6789");
        input.setColumns(20);
        panel = new JPanel();
        panel.add(label);
        panel.add(input);
        frame.add(panel);
    } catch (ParseException e) {
        System.err.println("Unable to add SSN");
    }
    frame.pack();
    frame.setVisible(true);
}

From source file:LINE_CAP_PROJECTING_SQUARE_and_LINE_CAP_BUTT.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from  www .j  a  va2 s.c o m
        PdfWriter.getInstance(document,
                new FileOutputStream("LINE_CAP_PROJECTING_SQUARE_and_LINE_CAP_BUTT.pdf"));
        document.open();

        Chunk c = new Chunk("Multiple lines", FontFactory.getFont(FontFactory.HELVETICA, 24));
        c.setUnderline(new Color(0x00, 0xFF, 0x00), 5.0f, 0.0f, 0.0f, -0.5f,
                PdfContentByte.LINE_CAP_PROJECTING_SQUARE);
        c.setUnderline(new Color(0x00, 0x00, 0xFF), 0.0f, 0.2f, 15.0f, 0.0f, PdfContentByte.LINE_CAP_BUTT);
        document.add(c);
    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:com.threerings.getdown.tools.Digester.java

/**
 * A command line entry point for the digester.
 *///from w  w w . j a v a2s.c o m
public static void main(String[] args) throws IOException, GeneralSecurityException {
    if (args.length != 1 && args.length != 4) {
        System.err.println("Usage: Digester app_dir [keystore_path password alias]");
        System.exit(255);
    }

    createDigest(new File(args[0]));
    if (args.length == 4) {
        signDigest(new File(args[0]), new File(args[1]), args[2], args[3]);
    }
}