Package java.io

Examples of java.io.IOError


     */
    public Iterator<Document> read(File file) {
        try {
            return read(new FileReader(file));
        } catch (IOException ioe) {
            throw new IOError(ioe);
        }
    }
View Full Code Here


                    // between tokens to simplify tokenization.
                    String[] tokens = line.split("\\s+");
                    sb.append(tokens[0]).append(" ");
                }
            } catch (IOException ioe) {
                throw new IOError(ioe);
            }

            // Return null if nothing was read, indicating that the above loop
            // reached the end of it's input.
            if (sb.length() == 0)
View Full Code Here

     */
    public Iterator<Document> read(File file) {
        try {
            return read(new FileReader(file));
        } catch (IOException ioe) {
            throw new IOError(ioe);
        }
    }
View Full Code Here

                    // that the dependency extractor is able to handle whatever
                    // format the lines are in.
                    sb.append(line).append("\n");
                }
            } catch (IOException ioe) {
                throw new IOError(ioe);
            }

            // Return null if nothing was read, indicating that the above loop
            // reached the end of it's input.
            if (sb.length() == 0)
View Full Code Here

                writer.println(sb.toString());
            }

            writer.close();
        } catch (IOException ioe) {
            throw new IOError(ioe);
        }

        return outFile;
    }
View Full Code Here

        DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = null;
        try {
            docBuilder = dbfac.newDocumentBuilder();
        } catch (ParserConfigurationException pce) {
            throw new IOError(new IOException(pce));
        }
        Document doc = docBuilder.newDocument();

        Element root = doc.createElement("gexf");
        root.setAttribute("xmlns","http://www.gexf.net/1.2draft");
        root.setAttribute("xmlns:viz", "http://www.gexf.net/1.2draft/viz");
        root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
        root.setAttribute("version","1.2");
        root.setAttribute("xsi:schemaLocation","http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd");
        doc.appendChild(root);

        Element graph = doc.createElement("graph");
        graph.setAttribute("defaultedgetype","undirected");
        root.appendChild(graph);

        Element nodes = doc.createElement("nodes");
        graph.appendChild(nodes);
        Element edges = doc.createElement("edges");
        graph.appendChild(edges);

        IntIterator vIter = g.vertices().iterator();
        while (vIter.hasNext()) {
            int vertex = vIter.next();
            Element node = doc.createElement("node");
            String vLabel = (vertexLabels == null)
                ? String.valueOf(vertex)
                : vertexLabels.lookup(vertex);
            if (vLabel == null)
                vLabel = String.valueOf(vertex);
            node.setAttribute("id", vLabel);
            node.setAttribute("label", vLabel);
            nodes.appendChild(node);
        }

        int edgeId = 0;
        for (Edge e : g.edges()) {
            Element edge = doc.createElement("edge");
            edges.appendChild(edge);
            edge.setAttribute("id", "" + (edgeId++));

            String sourceLabel = (vertexLabels == null)
                ? String.valueOf(e.from())
                : vertexLabels.lookup(e.from());
            if (sourceLabel == null)
                sourceLabel = String.valueOf(e.from());

            String targetLabel = (vertexLabels == null)
                ? String.valueOf(e.to())
                : vertexLabels.lookup(e.to());
            if (targetLabel == null)
                targetLabel = String.valueOf(e.to());

            edge.setAttribute("source", sourceLabel);
            edge.setAttribute("target", targetLabel);
        }

        // Set up a transformer
        try {
            TransformerFactory transfac = TransformerFactory.newInstance();
            Transformer trans = transfac.newTransformer();
            trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
            trans.setOutputProperty(OutputKeys.INDENT, "yes");
            trans.setOutputProperty(
                "{http://xml.apache.org/xslt}indent-amount", "2");
       
            // Create string from xml tree
            BufferedOutputStream bos =
                new BufferedOutputStream(new FileOutputStream(gexfFile));
            StreamResult result = new StreamResult(bos);
            DOMSource source = new DOMSource(doc);
            trans.transform(source, result);
            bos.close();        
        } catch (TransformerException te) {
            throw new IOError(new IOException(te));
        }
    }
View Full Code Here

        } catch (javax.xml.parsers.ParserConfigurationException pce) {
            pce.printStackTrace();
        } catch (org.xml.sax.SAXException saxe) {
            saxe.printStackTrace();
        } catch (IOException ioe) {
            throw new IOError(ioe);
        }

        // Set the final indexes based on what was in the configuration file.
        idIndex = id;
        formIndex = form;
View Full Code Here

        DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = null;
        try {
            docBuilder = dbfac.newDocumentBuilder();
        } catch (ParserConfigurationException pce) {
            throw new IOError(new IOException(pce));
        }
        Document doc = docBuilder.newDocument();

        Element root = doc.createElement("gexf");
        root.setAttribute("xmlns","http://www.gexf.net/1.2draft");
        root.setAttribute("xmlns:viz", "http://www.gexf.net/1.2draft/viz");
        root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
        root.setAttribute("version","1.2");
        root.setAttribute("xsi:schemaLocation","http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd");
        doc.appendChild(root);

        Element graph = doc.createElement("graph");
        graph.setAttribute("defaultedgetype","undirected");
        root.appendChild(graph);

        Element nodes = doc.createElement("nodes");
        graph.appendChild(nodes);
        Element edges = doc.createElement("edges");
        graph.appendChild(edges);

        IntIterator vIter = g.vertices().iterator();
        while (vIter.hasNext()) {
            int vertex = vIter.next();
            Element node = doc.createElement("node");
            node.setAttribute("id", String.valueOf(vertex));
            if (useLabels)
                node.setAttribute("label", vertexLabels.lookup(vertex));
            else
                node.setAttribute("label", String.valueOf(vertex));
            nodes.appendChild(node);
        }

        ColorGenerator cg = null;
        if (useColors)
            cg = new ColorGenerator();

        int edgeId = 0;
        for (E e : g.edges()) {
            Element edge = doc.createElement("edge");
            edges.appendChild(edge);
            edge.setAttribute("id", "" + (edgeId++));
            edge.setAttribute("source", String.valueOf(e.from()));
            edge.setAttribute("target", String.valueOf(e.to()));
            edge.setAttribute("label", String.valueOf(e.edgeType()));
            if (useColors) {
                Element cEdge = doc.createElement("viz:color");
                edge.appendChild(cEdge);
                Color c = edgeColors.get(e.edgeType());
                if (c == null) {
                    c = cg.next();
                    edgeColors.put(e.edgeType(), c);
                }
                cEdge.setAttribute("r", String.valueOf(c.getRed()));
                cEdge.setAttribute("g", String.valueOf(c.getGreen()));
                cEdge.setAttribute("b", String.valueOf(c.getBlue()));
            }
        }

        // Set up a transformer
        try {
            TransformerFactory transfac = TransformerFactory.newInstance();
            Transformer trans = transfac.newTransformer();
            trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
            trans.setOutputProperty(OutputKeys.INDENT, "yes");
            trans.setOutputProperty(
                "{http://xml.apache.org/xslt}indent-amount", "2");
       
            // Create string from xml tree
            BufferedOutputStream bos =
                new BufferedOutputStream(new FileOutputStream(f));
            StreamResult result = new StreamResult(bos);
            DOMSource source = new DOMSource(doc);
            trans.transform(source, result);
            bos.close();        
        } catch (TransformerException te) {
            throw new IOError(new IOException(te));
        }
    }
View Full Code Here

        DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = null;
        try {
            docBuilder = dbfac.newDocumentBuilder();
        } catch (ParserConfigurationException pce) {
            throw new IOError(new IOException(pce));
        }
        Document doc = docBuilder.newDocument();

        Element root = doc.createElement("gexf");
        root.setAttribute("xmlns","http://www.gexf.net/1.2draft");
        root.setAttribute("xmlns:viz", "http://www.gexf.net/1.2draft/viz");
        root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
        root.setAttribute("version","1.2");
        root.setAttribute("xsi:schemaLocation","http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd");
        doc.appendChild(root);

        Element graph = doc.createElement("graph");
        graph.setAttribute("defaultedgetype","undirected");
        root.appendChild(graph);

        Element nodes = doc.createElement("nodes");
        graph.appendChild(nodes);
        Element edges = doc.createElement("edges");
        graph.appendChild(edges);

        IntIterator vIter = g.vertices().iterator();
        while (vIter.hasNext()) {
            int vertex = vIter.next();
            Element node = doc.createElement("node");
            String vLabel = (vertexLabels == null)
                ? String.valueOf(vertex)
                : vertexLabels.lookup(vertex);
            if (vLabel == null)
                vLabel = String.valueOf(vertex);
            node.setAttribute("id", vLabel);
            node.setAttribute("label", vLabel);
            nodes.appendChild(node);
        }

        int edgeId = 0;
        for (WeightedEdge e : g.edges()) {
            Element edge = doc.createElement("edge");
            edges.appendChild(edge);
            edge.setAttribute("id", "" + (edgeId++));

            String sourceLabel = (vertexLabels == null)
                ? String.valueOf(e.from())
                : vertexLabels.lookup(e.from());
            if (sourceLabel == null)
                sourceLabel = String.valueOf(e.from());

            String targetLabel = (vertexLabels == null)
                ? String.valueOf(e.to())
                : vertexLabels.lookup(e.to());
            if (targetLabel == null)
                targetLabel = String.valueOf(e.to());

            edge.setAttribute("source", sourceLabel);
            edge.setAttribute("target", targetLabel);
            edge.setAttribute("weight", String.valueOf(e.weight()));
        }

        // Set up a transformer
        try {
            TransformerFactory transfac = TransformerFactory.newInstance();
            Transformer trans = transfac.newTransformer();
            trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
            trans.setOutputProperty(OutputKeys.INDENT, "yes");
            trans.setOutputProperty(
                "{http://xml.apache.org/xslt}indent-amount", "2");
       
            // Create string from xml tree
            BufferedOutputStream bos =
                new BufferedOutputStream(new FileOutputStream(gexfFile));
            StreamResult result = new StreamResult(bos);
            DOMSource source = new DOMSource(doc);
            trans.transform(source, result);
            bos.close();        
        } catch (TransformerException te) {
            throw new IOError(new IOException(te));
        }
    }
View Full Code Here

            DoubleBuffer contextBuffer =
                fc.map(MapMode.READ_WRITE, 0, size).asDoubleBuffer();
            fc.close();
            return new Duple<DoubleBuffer,File>(contextBuffer, f);
        } catch (IOException ioe) {
            throw new IOError(ioe);
        }
    }
View Full Code Here

TOP

Related Classes of java.io.IOError

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.