Example usage for java.lang String valueOf

List of usage examples for java.lang String valueOf

Introduction

In this page you can find the example usage for java.lang String valueOf.

Prototype

public static String valueOf(double d) 

Source Link

Document

Returns the string representation of the double argument.

Usage

From source file:MultiColumnSimplePDF.java

public static void main(String[] args) {
    try {// ww  w.j  a  va  2  s  .co m
        Document document = new Document();
        OutputStream out = new FileOutputStream("MultiColumnSimplePDF.pdf");
        PdfWriter.getInstance(document, out);
        document.open();

        MultiColumnText mct = new MultiColumnText();

        mct.addRegularColumns(document.left(), document.right(), 10f, 3);

        for (int i = 0; i < 30; i++) {
            mct.addElement(new Paragraph(String.valueOf(i + 1)));

            Paragraph p = new Paragraph(
                    "text text text text text text text text text text text text text text text text text text text text text text text text text text text ",
                    FontFactory.getFont("Helvetica", 10, Font.BOLDITALIC, Color.BLACK));
            p.setAlignment(Element.ALIGN_CENTER);
            p.setLeading(12f);
            mct.addElement(p);
        }
        document.add(mct);
        document.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:MultiColumnRegularColumnsPDF.java

public static void main(String[] args) {
    try {/*w ww  .j  ava  2  s .  c  o  m*/
        Document document = new Document();
        OutputStream out = new FileOutputStream("MultiColumnRegularColumnsPDF.pdf");
        PdfWriter.getInstance(document, out);
        document.open();

        MultiColumnText mct = new MultiColumnText();
        mct.setColumnsRightToLeft(true);
        mct.addRegularColumns(document.left(), document.right(), 10f, 3);

        for (int i = 0; i < 30; i++) {
            mct.addElement(new Paragraph(String.valueOf(i + 1)));
            Paragraph p = new Paragraph("text text text text text text text text text text text ",
                    FontFactory.getFont("Helvetica", 10, Font.NORMAL, Color.BLACK));
            p.setAlignment(Element.ALIGN_LEFT);
            p.setLeading(12f);

            mct.addElement(p);
        }

        document.add(mct);
        document.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:SplitRowsPDF.java

public static void main(String[] args) {
    Document document1 = new Document(PageSize.A4.rotate(), 10, 10, 10, 10);
    try {/*from ww w.  j a  v  a  2  s. c  o m*/
        PdfWriter.getInstance(document1, new FileOutputStream("SplitRowsPDF.pdf"));
        document1.open();

        String text = "Text Text Text Text Text Text Text Text Text";
        PdfPTable table = new PdfPTable(2);
        PdfPCell largeCell;
        Phrase phrase;
        for (int i = 0; i < 10; i++) {
            phrase = new Phrase(text);
            for (int j = 0; j < i; j++) {
                phrase.add(new Phrase(text));
            }
            if (i == 7)
                phrase = new Phrase(text);
            table.addCell(String.valueOf(i));
            largeCell = new PdfPCell(phrase);
            table.addCell(largeCell);
        }
        document1.add(table);
        table.setSplitLate(true);

    } catch (Exception de) {
        de.printStackTrace();
    }
    document1.close();
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();//from  w  w  w.  j a  v  a  2  s  .  co  m

    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100);
    table.setHeaderRows(1);
    PdfPCell h1 = new PdfPCell(new Paragraph("Header 1"));
    h1.setGrayFill(0.7f);
    table.addCell(h1);
    PdfPCell h2 = new PdfPCell(new Paragraph("Header 2"));
    h2.setGrayFill(0.7f);
    table.addCell(h2);
    PdfPCell cell;
    for (int row = 1; row <= 2000; row++) {
        document.add(table);
        table.deleteBodyRows();
        table.setSkipFirstHeader(true);
        cell = new PdfPCell(new Paragraph(String.valueOf(row)));
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph("Quick brown fox jumps over the lazy dog."));
        table.addCell(cell);
    }
    document.add(table);
    document.close();
}

From source file:com.glaf.core.test.EncodeTest.java

public static void main(String[] args) {
    for (int i = 0; i < 100; i++) {
        String str = RequestUtils.encodeString(String.valueOf(i) + "_" + UUID32.getUUID());
        System.out.println(RequestUtils.decodeString(str));
    }/*from w  w  w. j av a 2  s .  co  m*/
    System.out.println();
    System.out.println(RequestUtils.encodeString("20140805/lfm-0000001"));
    System.out.println(RequestUtils.decodeString(
            "4b6a68716c64614e75724a4448353538514b57323065724536556d65614a6d324e497665594f6d493452614232446a415353656969734b526d426a41306b697175365536393150716264513d"));
    String salt = DigestUtils.md5Hex(SystemConfig.getToken());
    System.out.println(salt);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    Document doc = db.parse(new InputSource(
            new StringReader("<emp><empname><firstName></firstName><lastName></lastName></empname></emp>")));
    NodeList customerNodes = doc.getElementsByTagName("empname");
    for (int i = 0; i < customerNodes.getLength(); i++) {
        NodeList children = customerNodes.item(i).getChildNodes();
        for (int j = 0; j < children.getLength(); j++) {
            String childNode = children.item(j).getNodeName();
            if (childNode.equalsIgnoreCase("firstName")) {
                children.item(j).setTextContent(String.valueOf("John"));
            } else if (childNode.equalsIgnoreCase("lastName")) {
                children.item(j).setTextContent(String.valueOf("Doe"));
            }// w  w w. j  a va 2s.  co  m
        }
    }
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer transformer = tf.newTransformer();
    transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
    StringWriter writer = new StringWriter();
    transformer.transform(new DOMSource(doc), new StreamResult(writer));
    System.out.println(writer.getBuffer().toString());
}

From source file:MyTest.ParseJson.java

public static void main(String args[]) {
    try {//  w  ww.  j a v  a 2s  .  c  o  m
        FileReader reader = new FileReader(
                new File("data/NGS___RNA-seq_differential_expression_analysis-v1.ga"));
        System.out.println(reader);
        JSONParser parser = new JSONParser();
        JSONObject jo = (JSONObject) parser.parse(reader);
        JSONObject jsteps = (JSONObject) jo.get("steps");

        System.out.println(jsteps.size());
        System.out.println("---------------------------------------------------");
        for (int i = 0; i < jsteps.size(); i++) {
            JSONObject jstep_detail = (JSONObject) jsteps.get(String.valueOf(i));
            getDetailInfo(jstep_detail);

        }

    } catch (FileNotFoundException ex) {
        Logger.getLogger(ParseJson.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(ParseJson.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ParseException ex) {
        Logger.getLogger(ParseJson.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:com.bia.config.Main.java

public static void main(String[] args) throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/spring/applicationContext*.xml");

    EmployeeCassandraServiceImpl service = context.getBean(EmployeeCassandraServiceImpl.class);

    Emp emp = new Emp();
    emp.setId((new Date()).toString());
    String username = "IM-" + new Date();
    emp.setUsername(username);/*from  w  ww .j  ava 2 s  .  c  o  m*/
    emp.setJoinDate(new Date());
    emp.setStorageSize(10.0);
    emp.setContent(ByteBuffer
            .wrap(IOUtils.toByteArray(Main.class.getClassLoader().getResourceAsStream("log4j.properties"))));

    service.saveEmployee(emp);
    int count = 0;
    for (Emp e : service.findAllEmployees()) {
        System.out.println(e + String.valueOf(e.getContent()));
        System.out.println(new String(e.getContent().array()));
        count++;
    }

    System.out.println("done " + count);

    System.out.println(service.findByUsername(username));

}

From source file:com.timothyyip.face.FaceDetector.java

public static void main(String[] args) throws ImageReadException, IOException, ImageWriteException {

    Detector detector = new Detector("C:\\Code\\Java\\FaceDetector\\lib\\haarcascade_frontalface_default.xml");

    flickr.photoservice.flickrresponse.Rsp response = getFlickrPhotos();

    for (Photo photo : response.getPhotos().getPhoto()) {
        String timestamp = String.valueOf(Calendar.getInstance().getTimeInMillis());
        BufferedImage originalImage = getPhysicalFlickrImage(photo);

        if (originalImage != null) {
            File originalImageFile = new File(
                    "C:\\Code\\Java\\FaceDetector\\images\\original\\" + timestamp + ".jpg");

            //Sanselan.writeImage(originalImage, originalImageFile, ImageFormat.IMAGE_FORMAT_JPEG, null);
            ImageIO.write(originalImage, "JPG", originalImageFile);
            List<Rectangle> res = detector.getFaces(originalImageFile.getAbsolutePath(), 3, 1.25f, 0.1f, 1,
                    false);//w w w  . j ava  2 s.  co m

            for (Rectangle face : res) {
                BufferedImage faceImage = originalImage.getSubimage(face.x, face.y, face.width, face.height);

                Sanselan.writeImage(faceImage,
                        new File("C:\\Code\\Java\\FaceDetector\\images\\"
                                + String.valueOf(Calendar.getInstance().getTimeInMillis()) + ".png"),
                        ImageFormat.IMAGE_FORMAT_PNG, null);
            }

        }
    }
}

From source file:org.eclipse.swt.snippets.Snippet275.java

public static void main(String[] args) {
    final int INTERVAL = 888;
    final Display display = new Display();
    final Image image = new Image(display, 750, 750);
    GC gc = new GC(image);
    gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
    gc.fillRectangle(image.getBounds());
    gc.dispose();/*from   www  .  j  ava2s . c o m*/

    Shell shell = new Shell(display);
    shell.setText("Snippet 275");
    shell.setBounds(10, 10, 790, 790);
    final Canvas canvas = new Canvas(shell, SWT.NONE);
    canvas.setBounds(10, 10, 750, 750);
    canvas.addListener(SWT.Paint, event -> {
        value = String.valueOf(System.currentTimeMillis());
        event.gc.drawImage(image, 0, 0);
        event.gc.drawString(value, 10, 10, true);
    });
    display.timerExec(INTERVAL, new Runnable() {
        @Override
        public void run() {
            if (canvas.isDisposed())
                return;
            // canvas.redraw (); // <-- bad, damages more than is needed
            GC gc = new GC(canvas);
            Point extent = gc.stringExtent(value + '0');
            gc.dispose();
            canvas.redraw(10, 10, extent.x, extent.y, false);
            display.timerExec(INTERVAL, this);
        }
    });
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    image.dispose();
    display.dispose();
}