Package java.io

Examples of java.io.OutputStream


    private void testBlob(int length) throws Exception {
        Random r = new Random(length);
        byte[] data = new byte[length];
        r.nextBytes(data);
        Blob b = conn.createBlob();
        OutputStream out = b.setBinaryStream(1);
        out.write(data, 0, data.length);
        out.close();
        stat.execute("delete from test");
        PreparedStatement prep = conn.prepareStatement("insert into test values(?, ?)");
        prep.setInt(1, 1);
        prep.setBlob(2, b);
        prep.execute();
View Full Code Here


        lock.lockForCommit();
        try {
            long t = System.currentTimeMillis();
            try {
                shiftFiles(0);
                OutputStream os = new FileOutputStream(makeFile());
                try {
                    new XStream().toXML(statsData, os);
                } finally {
                    os.close();
                }
            } catch (Exception e) {
                logger.error("Could not write stats data to " + makeFile().getAbsolutePath(), e);
            } finally {
                logger.debug("stats serialized in " + (System.currentTimeMillis() - t) + "ms.");
View Full Code Here

     * @since 4.2
     */
    public static PrintStream getPrintStream(OutputStream resultsOutput, BufferedReader expectedResultsInput, PrintStream defaultPrintStream) {
        PrintStream out = null;
        if (defaultPrintStream == null) {
            defaultPrintStream = new PrintStream(new OutputStream () {
                                                     public void write(int b) throws IOException {}
                                                 });
        }
        if (resultsOutput == null && expectedResultsInput == null) {
            out = defaultPrintStream;
View Full Code Here

            return anonymousNode;
          }
        });
    File modelFile = new File(directory, "graph");
    Model model = JenaUtil.getModelFromGraph(naturalizedGraph);
    OutputStream modelOut = new FileOutputStream(modelFile);
    try {
      model.write(modelOut, "N-TRIPLE");
    } finally {
      modelOut.close();
    }
  }
View Full Code Here

    Resource componentRes = metaInfModel.createResource(node.getURIRef());
    componentRes.addProperty(RDF.type, type);
    componentRes.addProperty(METAMODEL.hashCode, metaInfModel
        .createTypedLiteral(component.hashCode()));

    OutputStream metaInfOut = new FileOutputStream(metaInfFile);
    try {
      metaInfModel.write(metaInfOut, "N-TRIPLE");
    } finally {
      metaInfOut.close();
    }
    indexModel.add(metaInfModel);

  }
View Full Code Here

          throw new RuntimeException(e);
        }
        componentRes.addProperty(METAMODEL.containsNonTerminalMolecule,
            metaInfModel.createResource(moleculeName.getURIRef()));
      }
      OutputStream metaInfOut = new FileOutputStream(metaInfFile);
      try {
        metaInfModel.write(metaInfOut, "N-TRIPLE");
      } finally {
        metaInfOut.close();
      }
      indexModel.add(metaInfModel);
      result = componentDirectory.node;
      synchronized (currentlyBeingAdded) {
        currentlyBeingAdded.remove(functionallyGroundedNode);
View Full Code Here

        super.setBody(new MessageBody2Write() {
          //<?xml-stylesheet type="text/xsl" href="/stylesheets/topic"?>
          public void writeTo(WritableByteChannel out) throws IOException {
            Model model = JenaUtil.getModelFromGraph(graph);
            //TODO deliver other formats
            OutputStream outS = Channels.newOutputStream(out);
           
            if (stylesheet != null) {
              outS.write(("<?xml-stylesheet type=\"text/xsl\" href=\""+stylesheet+"\"?>\n").getBytes("utf-8"));
            }
            Writer outW = new OutputStreamWriter(outS, "utf-8");
            new Serializer().serialize(model, "", outW);
            outW.flush();
            //model.write(outS);
            outS.close();
          }
         
        });
      }
View Full Code Here

         
          // send shutdown command to specified port
          Socket socket = new Socket();
          socket.connect(new InetSocketAddress("127.0.0.1", Integer.parseInt(serverPort)), 1000);
          socket.setSoTimeout(5000);
                  OutputStream stream = socket.getOutputStream();
                  for (int i = 0; i < shutdownCommand.length(); i++) {
                      stream.write(shutdownCommand.charAt(i));
                  }
                  stream.flush();
                  stream.close();
                  socket.close();

          monitor.worked(1);
         
          monitor.setTaskName("Waiting for wga shutdown ...");
View Full Code Here

        + serverBinding.getPort() + "/danbri");
    HttpURLConnection connection = (HttpURLConnection) serverURL
        .openConnection();
    connection.setDoOutput(true);
    connection.setRequestMethod("PUT");
    OutputStream out = connection.getOutputStream();
    model.write(out);
    int responseCode = connection.getResponseCode();
    assertEquals(403, responseCode);
    webServer.stop();
View Full Code Here

    HttpURLConnection connection = (HttpURLConnection) sourceURL
        .openConnection();
    connection.addRequestProperty("Cookie", "login=beta:tester");
    connection.setDoOutput(true);
    connection.setRequestMethod("PUT");
    OutputStream out = connection.getOutputStream();
    model.write(out);
    int responseCode = connection.getResponseCode();
    assertEquals(200, responseCode);
    connection.disconnect();
    Model retrievedModel = ModelFactory.createDefaultModel();
View Full Code Here

TOP

Related Classes of java.io.OutputStream

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.