Example usage for java.io PrintStream println

List of usage examples for java.io PrintStream println

Introduction

In this page you can find the example usage for java.io PrintStream println.

Prototype

public void println(Object x) 

Source Link

Document

Prints an Object and then terminate the line.

Usage

From source file:de.unisb.cs.st.javaslicer.jung.ShowJungGraph.java

private static void printHelp(Options options, PrintStream out) {
    out.println("Usage: " + ShowJungGraph.class.getSimpleName() + " [<options>] <file> <slicing criterion>");
    out.println("where <file> is the input trace file");
    out.println("      <slicing criterion> has the form <loc>[(<occ>)]:<var>[,<loc>[(<occ>)]:<var>]*");
    out.println("      <options> may be one or more of");
    HelpFormatter formatter = new HelpFormatter();
    PrintWriter pw = new PrintWriter(out, true);
    formatter.printOptions(pw, 120, options, 5, 3);
}

From source file:edu.umn.cs.spatialHadoop.nasa.MultiHDFPlot.java

private static void createKML(FileSystem outFs, Path output, Rectangle mbr, OperationsParams params)
        throws IOException, ParseException {
    FileStatus[] all_images = outFs.listStatus(output, new PathFilter() {
        @Override// ww  w  .  j  a v  a 2 s. c  o  m
        public boolean accept(Path path) {
            return path.getName().matches("\\d+\\.\\d+\\.\\d+\\.png");
        }
    });

    Path kmlPath = new Path(output, "index.kml");
    PrintStream ps = new PrintStream(outFs.create(kmlPath));
    ps.println("<?xml version='1.0' encoding='UTF-8'?>");
    ps.println("<kml xmlns='http://www.opengis.net/kml/2.2'>");
    ps.println("<Folder>");
    String mbrStr = String.format(
            "<LatLonBox><west>%f</west><south>%f</south><east>%f</east><north>%f</north></LatLonBox>", mbr.x1,
            mbr.y1, mbr.x2, mbr.y2);
    for (FileStatus image : all_images) {
        SimpleDateFormat fileDateFormat = new SimpleDateFormat("yyyy.MM.dd");
        SimpleDateFormat kmlDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String name = image.getPath().getName();
        int dotIndex = name.lastIndexOf('.');
        name = name.substring(0, dotIndex);
        Date date = fileDateFormat.parse(name);
        String kmlDate = kmlDateFormat.format(date);
        ps.println("<GroundOverlay>");
        ps.println("<name>" + kmlDate + "</name>");
        ps.println("<TimeStamp><when>" + kmlDate + "</when></TimeStamp>");
        ps.println("<Icon><href>" + image.getPath().getName() + "</href></Icon>");
        ps.println(mbrStr);
        ps.println("</GroundOverlay>");
    }
    String scale = params.get("scale", "none").toLowerCase();
    if (scale.equals("vertical")) {
        ps.println("<ScreenOverlay>");
        ps.println("<name>Scale</name>");
        ps.println("<Icon><href>scale.png</href></Icon>");
        ps.println("<overlayXY x='1' y='0.5' xunits='fraction' yunits='fraction'/>");
        ps.println("<screenXY x='1' y='0.5' xunits='fraction' yunits='fraction'/>");
        ps.println("<rotationXY x='0' y='0' xunits='fraction' yunits='fraction'/>");
        ps.println("<size x='0' y='0.7' xunits='fraction' yunits='fraction'/>");
        ps.println("</ScreenOverlay>");
    } else if (scale.equals("horizontal")) {
        ps.println("<ScreenOverlay>");
        ps.println("<name>Scale</name>");
        ps.println("<Icon><href>scale.png</href></Icon>");
        ps.println("<overlayXY x='0.5' y='0' xunits='fraction' yunits='fraction'/>");
        ps.println("<screenXY x='0.5' y='0' xunits='fraction' yunits='fraction'/>");
        ps.println("<rotationXY x='0' y='0' xunits='fraction' yunits='fraction'/>");
        ps.println("<size x='0.7' y='0' xunits='fraction' yunits='fraction'/>");
        ps.println("</ScreenOverlay>");
    }
    ps.println("</Folder>");
    ps.println("</kml>");
    ps.close();
}

From source file:ar.com.qbe.siniestros.model.utils.MimeMagic.Magic.java

/**
 * print a magic match//  w w w.j a va2s .c o  m
 *
 * @param stream DOCUMENT ME!
 * @param match DOCUMENT ME!
 * @param spacing DOCUMENT ME!
 */
public static void printMagicMatch(PrintStream stream, MagicMatch match, String spacing) {
    stream.println(spacing + "=============================");
    stream.println(spacing + "mime type: " + match.getMimeType());
    stream.println(spacing + "description: " + match.getDescription());
    stream.println(spacing + "extension: " + match.getExtension());
    stream.println(spacing + "test: " + new String(match.getTest().array()));
    stream.println(spacing + "bitmask: " + match.getBitmask());
    stream.println(spacing + "offset: " + match.getOffset());
    stream.println(spacing + "length: " + match.getLength());
    stream.println(spacing + "type: " + match.getType());
    stream.println(spacing + "comparator: " + match.getComparator());
    stream.println(spacing + "=============================");

    Collection submatches = match.getSubMatches();
    Iterator i = submatches.iterator();

    while (i.hasNext()) {
        printMagicMatch(stream, (MagicMatch) i.next(), spacing + "    ");
    }
}

From source file:Main.java

protected static void print(PrintStream out, Node node) {
    if (node == null)
        return;/*from  w  w w . j  a v  a  2 s  .co m*/
    short type = node.getNodeType();
    switch (type) {
    case Node.DOCUMENT_NODE: {
        out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        //out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n");
        NodeList nodelist = node.getChildNodes();
        int size = nodelist.getLength();
        for (int i = 0; i < size; i++)
            print(out, nodelist.item(i));
        break;
    }

    case Node.DOCUMENT_TYPE_NODE: {
        DocumentType docType = (DocumentType) node;
        out.print("<!DOCTYPE " + getDocumentTypeData(docType) + ">\n");
        break;
    }

    case Node.ELEMENT_NODE: {
        out.print('<');
        out.print(node.getNodeName());
        NamedNodeMap map = node.getAttributes();
        if (map != null) {
            int size = map.getLength();
            for (int i = 0; i < size; i++) {
                Attr attr = (Attr) map.item(i);
                out.print(' ');
                out.print(attr.getNodeName());
                out.print("=\"");
                out.print(normalize(attr.getNodeValue()));
                out.print('"');
            }
        }

        if (!node.hasChildNodes())
            out.print("/>");
        else {
            out.print('>');
            NodeList nodelist = node.getChildNodes();
            int numChildren = nodelist.getLength();
            for (int i = 0; i < numChildren; i++)
                print(out, nodelist.item(i));

            out.print("</");
            out.print(node.getNodeName());
            out.print('>');
        }
        break;
    }

    case Node.ENTITY_REFERENCE_NODE: {
        NodeList nodelist = node.getChildNodes();
        if (nodelist != null) {
            int size = nodelist.getLength();
            for (int i = 0; i < size; i++)
                print(out, nodelist.item(i));

        }
        break;
    }

    case Node.CDATA_SECTION_NODE: {
        out.print(normalize(node.getNodeValue()));
        break;
    }

    case Node.TEXT_NODE: {
        out.print(normalize(node.getNodeValue()));
        break;
    }

    case Node.PROCESSING_INSTRUCTION_NODE: {
        out.print("<?");
        out.print(node.getNodeName());
        String s = node.getNodeValue();
        if (s != null && s.length() > 0) {
            out.print(' ');
            out.print(s);
        }
        out.print("?>");
        break;
    }

    case Node.COMMENT_NODE: {
        out.print("<!--");
        out.print(node.getNodeValue());
        out.print("-->");
        break;
    }

    default: {
        out.print(normalize(node.getNodeValue()));
        break;
    }
    }
    out.flush();
}

From source file:de.unisb.cs.st.javaslicer.slicing.DirectSlicer.java

private static void printHelp(Options options, PrintStream out) {
    out.println("Usage: " + DirectSlicer.class.getSimpleName() + " [<options>] <file> <slicing criterion>");
    out.println("where <file> is the input trace file, and <options> may be one or more of");
    out.println("      <slicing criterion> has the form <loc>[(<occ>)]:<var>[,<loc>[(<occ>)]:<var>]*");
    out.println("      <options> may be one or more of");
    HelpFormatter formatter = new HelpFormatter();
    PrintWriter pw = new PrintWriter(out, true);
    formatter.printOptions(pw, 120, options, 5, 3);
}

From source file:edu.cmu.cs.lti.ark.fn.parsing.DataPrep.java

public static void writeFeatureIndex(String alphabetFilename) {
    int numFeatures = featureIndex.size();
    PrintStream printStream = FileUtil.openOutFile(alphabetFilename);
    printStream.println(numFeatures);
    String buf[] = new String[numFeatures + 1];
    for (String feature : featureIndex.keySet()) {
        buf[featureIndex.get(feature)] = feature;
    }/*w  w w  .  ja  v  a  2 s.  co m*/
    for (int i = 1; i <= numFeatures; i++) {
        printStream.println(buf[i]);
    }
    printStream.close();
}

From source file:com.github.dakusui.symfonion.CLI.java

private static void printError(PrintStream ps, Throwable t) {
    ps.println(String.format("symfonion: %s", t.getMessage()));
}

From source file:com.adaptris.util.text.mime.MultiPartOutput.java

/**
 * Write the internet headers out to the supplied outputstream
 *///from  ww w  . ja  va 2s .c  om
private static void writeHeaders(InternetHeaders header, OutputStream out)
        throws IOException, MessagingException {

    Enumeration e = header.getAllHeaderLines();
    PrintStream p = new PrintStream(out);
    while (e.hasMoreElements()) {
        p.println(e.nextElement().toString());
    }
    p.println("");
    p.flush();
}

From source file:Main.java

protected static void print(PrintStream out, Node node) {
    if (node == null)
        return;/*from   www .java  2 s .c om*/
    short type = node.getNodeType();
    switch (type) {
    case Node.DOCUMENT_NODE: {
        out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        // out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n");
        NodeList nodelist = node.getChildNodes();
        int size = nodelist.getLength();
        for (int i = 0; i < size; i++)
            print(out, nodelist.item(i));
        break;
    }

    case Node.DOCUMENT_TYPE_NODE: {
        DocumentType docType = (DocumentType) node;
        out.print("<!DOCTYPE " + getDocumentTypeData(docType) + ">\n");
        break;
    }

    case Node.ELEMENT_NODE: {
        out.print('<');
        out.print(node.getNodeName());
        NamedNodeMap map = node.getAttributes();
        if (map != null) {
            int size = map.getLength();
            for (int i = 0; i < size; i++) {
                Attr attr = (Attr) map.item(i);
                out.print(' ');
                out.print(attr.getNodeName());
                out.print("=\"");
                out.print(normalize(attr.getNodeValue()));
                out.print('"');
            }
        }

        if (!node.hasChildNodes())
            out.print("/>");
        else {
            out.print('>');
            NodeList nodelist = node.getChildNodes();
            int numChildren = nodelist.getLength();
            for (int i = 0; i < numChildren; i++)
                print(out, nodelist.item(i));

            out.print("</");
            out.print(node.getNodeName());
            out.print('>');
        }
        break;
    }

    case Node.ENTITY_REFERENCE_NODE: {
        NodeList nodelist = node.getChildNodes();
        if (nodelist != null) {
            int size = nodelist.getLength();
            for (int i = 0; i < size; i++)
                print(out, nodelist.item(i));

        }
        break;
    }

    case Node.CDATA_SECTION_NODE: {
        out.print(normalize(node.getNodeValue()));
        break;
    }

    case Node.TEXT_NODE: {
        out.print(normalize(node.getNodeValue()));
        break;
    }

    case Node.PROCESSING_INSTRUCTION_NODE: {
        out.print("<?");
        out.print(node.getNodeName());
        String s = node.getNodeValue();
        if (s != null && s.length() > 0) {
            out.print(' ');
            out.print(s);
        }
        out.print("?>");
        break;
    }

    case Node.COMMENT_NODE: {
        out.print("<!--");
        out.print(node.getNodeValue());
        out.print("-->");
        break;
    }

    default: {
        out.print(normalize(node.getNodeValue()));
        break;
    }
    }
    out.flush();
}

From source file:Main.java

/**
 * Used for debuging/*from   ww w.j  a  va  2 s .  com*/
 * 
 * @param parent
 *            Element
 * @param out
 *            PrintStream
 * @param deep
 *            boolean
 * @param prefix
 *            String
 */
public static void printChildElements(Element parent, PrintStream out, boolean deep, String prefix) {
    out.print(prefix + "<" + parent.getNodeName());
    NamedNodeMap attrs = parent.getAttributes();
    Node node;
    for (int i = 0; i < attrs.getLength(); i++) {
        node = attrs.item(i);
        out.print(" " + node.getNodeName() + "=\"" + node.getNodeValue() + "\"");
    }
    out.println(">");

    // String data = getElementTextValueDeprecated(parent);
    String data = parent.getNodeValue();
    if (data != null && data.trim().length() > 0) {
        out.println(prefix + "\t" + data);
    }

    data = getElementCDataValue(parent);
    if (data != null && data.trim().length() > 0) {
        out.println(prefix + "\t<![CDATA[" + data + "]]>");
    }

    NodeList nodes = parent.getChildNodes();
    for (int i = 0; i < nodes.getLength(); i++) {
        node = nodes.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            if (deep) {
                printChildElements((Element) node, out, deep, prefix + "\t");
            } else {
                out.println(prefix + node.getNodeName());
            }
        }
    }

    out.println(prefix + "</" + parent.getNodeName() + ">");
}