Package java.io

Examples of java.io.OutputStream


    HttpURLConnection connection = (HttpURLConnection) sourceURL
        .openConnection();
    connection.addRequestProperty("Cookie", "login=beta:wrong");
    connection.setDoOutput(true);
    connection.setRequestMethod("PUT");
    OutputStream out = connection.getOutputStream();
    model.write(out);
    int responseCode = connection.getResponseCode();
    assertEquals(403, responseCode);
    connection.disconnect();
    webServer.stop();
View Full Code Here


            // byte array transfers
            String s1 = "Hello world";

            log.info("Putting s1");
            OutputStream out = ftp.uploadStream("Hello.txt");
            try {
                out.write(s1.getBytes());
            }
            finally {
                out.close(); // MUST be closed to complete the transfer
            }

            log.info("Retrieving as s2");
            StringBuffer s2 = new StringBuffer();
            InputStream in = ftp.downloadStream("Hello.txt");
View Full Code Here

      FileStorageManager sm = getStorageManager(1024, null, null);
        String tsID = "0";     //$NON-NLS-1$
        // Add one batch
        FileStore store = sm.createFileStore(tsID);
        String contentOrig = new String("some file content this will stored in same tmp file with another");
        OutputStream out = store.createOutputStream();
        out.write(contentOrig.getBytes(), 0, contentOrig.getBytes().length);
        out.close();

        out = store.createOutputStream();
        long start = store.getLength();
        byte[] bytesOrig = new byte[2048];
        r.nextBytes(bytesOrig);
        out.write(bytesOrig, 0, 2048);
       
        byte[] readContent = new byte[2048];
        InputStream in = store.createInputStream(0, contentOrig.getBytes().length);       
      int c = in.read(readContent, 0, 3000);
         assertEquals(contentOrig, new String(readContent, 0, c));        
View Full Code Here

                lobManager.updateReferences(batchManager.lobIndexes, tuple);
              }
            }
            synchronized (batchManager.store) {
              offset = batchManager.getOffset();
              OutputStream fsos = new BufferedOutputStream(batchManager.store.createOutputStream(), IO_BUFFER_SIZE);
                    ObjectOutputStream oos = new ObjectOutputStream(fsos);
                    batch.writeExternal(oos);
                    oos.close();
                    long size = batchManager.store.getLength() - offset;
                    long[] info = new long[] {offset, size};
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

    plot.setForegroundAlpha(0.65f);
    plot.setNoDataMessage("No data to display");
    plot.setLabelGenerator(new CustomLabelGenerator(numFormatter));

    // print the chart image directly the the HTTP stream
    OutputStream out = response.getOutputStream();
    response.setContentType("image/jpeg");
     
    try
    {
      ChartUtilities.writeChartAsJPEG(out, 1.0f, pieChart, 400, 300);
    }catch(IOException e){
      logger.error("[getOpportunityPieData] Exception thrown.", e);
      throw new ServletException(e);
    }finally{
      out.close();
    }

    session.removeAttribute("salesPieChartParams");

    // return null (don't forward anywhere, we've done the output already)
View Full Code Here

    // format the number labels on the Y axis
    // TODO: figure out how to format the Y axis values as US Currency


    // print the chart image directly the the HTTP stream
    OutputStream out = response.getOutputStream();
    response.setContentType("image/jpeg");
     
    try
    {
      ChartUtilities.writeChartAsJPEG(out, 1.0f, barChart, 400, 300);
    }catch(IOException e){
      logger.error("[getOpportunityPieData] Exception thrown.", e);
      throw new ServletException(e);
    }finally{
      out.close();
    }

    session.removeAttribute("salesBarChartParams");

    // return null (don't forward anywhere, we've done the output already)
View Full Code Here

  public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
    String archive = (String) workItem.getParameter("Archive");
    List<File> files = (List<File>) workItem.getParameter("Files");
   
    try {
          OutputStream outputStream = new FileOutputStream( new File( archive) );         
          ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream("tar", outputStream);
         
      if (files != null) {
        for (File file: files) {
              final TarArchiveEntry entry = new TarArchiveEntry("testdata/test1.xml");
View Full Code Here

    return socket;
  }

  private void doTunnelHandshake(Socket tunnel, InetAddress host, int port)
    throws IOException {
    OutputStream out = tunnel.getOutputStream();
    String msg = "CONNECT " + host.getHostName() + ":" + port + " HTTP/1.0\r\n\r\n";
   
    byte b[];
    try {
      // We really do want ASCII7 -- the http protocol doesn't change
      // with locale.
      b = msg.getBytes("ASCII7");
    } catch (UnsupportedEncodingException ignored) {
      // If ASCII7 isn't there, something serious is wrong
      b = msg.getBytes();
    }
    out.write(b);
    out.flush();

    // We need to store the reply so we can create a detailed
    // error message to the user.
    byte    reply[] = new byte[200];
    int    replyLen = 0;
View Full Code Here

    }

    private void testLZFStreamClose() throws IOException {
        String fileName = getBaseDir() + "/temp";
        IOUtils.createDirs(fileName);
        OutputStream fo = IOUtils.openFileOutputStream(fileName, false);
        LZFOutputStream out = new LZFOutputStream(fo);
        out.write("Hello".getBytes());
        out.close();
        InputStream fi = IOUtils.openFileInputStream(fileName);
        LZFInputStream in = new LZFInputStream(fi);
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.