Package java.io

Examples of java.io.OutputStream


                CompressTool.expand(out, test, 0);
                assertEquals(buff, test);
            }
            for (String a : new String[] { null, "LZF", "DEFLATE", "ZIP", "GZIP" }) {
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                OutputStream out2 = CompressTool.wrapOutputStream(out, a, "test");
                IOUtils.copy(new ByteArrayInputStream(buff), out2);
                out2.close();
                InputStream in = new ByteArrayInputStream(out.toByteArray());
                in = CompressTool.wrapInputStream(in, a, "test");
                out.reset();
                IOUtils.copy(in, out);
                assertEquals(buff, out.toByteArray());
View Full Code Here


        // If parameter is dir, change saveInDir to dir
        line = getLine(is);
        continue;
      }
      try {
        OutputStream os = null;
        String path = null;
        if (saveFiles)
          os = new FileOutputStream(path = getFileName(saveInDir,
              fileInfo.clientFileName));
        else
          os = new ByteArrayOutputStream(ONE_MB);
        boolean readingContent = true;
        byte previousLine[] = new byte[2 * ONE_MB];
        byte temp[] = null;
        byte currentLine[] = new byte[2 * ONE_MB];
        int read, read3;
        if ((read = is.readLine(previousLine, 0, previousLine.length)) == -1) {
          line = null;
          break;
        }
        while (readingContent) {
          if ((read3 = is
              .readLine(currentLine, 0, currentLine.length)) == -1) {
            line = null;
            break;
          }
          if (compareBoundary(boundary, currentLine)) {
            os.write(previousLine, 0, read - 2);
            line = new String(currentLine, 0, read3);
            break;
          } else {
            os.write(previousLine, 0, read);
            temp = currentLine;
            currentLine = previousLine;
            previousLine = temp;
            read = read3;
          }// end else
        }// end while
        os.flush();
        os.close();
        if (!saveFiles) {
          ByteArrayOutputStream baos = (ByteArrayOutputStream) os;
          fileInfo.setFileContents(baos.toByteArray());
        } else
          fileInfo.file = new File(path);
View Full Code Here

    /**
     * Internal use, runs the render process
     */
    private static void doRenderToPDF(ITextRenderer renderer, String pdf)
            throws IOException, DocumentException {
        OutputStream os = null;
        try {
            os = new FileOutputStream(pdf);
            renderer.layout();
            renderer.createPDF(os);

            os.close();
            os = null;
        } finally {
            if (os != null) {
                try {
                    os.close();
                } catch (IOException e) {
                    // ignore
                }
            }
        }
View Full Code Here

        listRecursive(list, base);
        if (list.size() == 0) {
            FileOutputStream out = new FileOutputStream(zipFile);
            out.close();
        } else {
            OutputStream out = null;
            try {
                out = new FileOutputStream(zipFile);
                ZipOutputStream zipOut = new ZipOutputStream(out);
                String baseName = base.getAbsolutePath();
                for (File f : list) {
View Full Code Here

        Thread.sleep(100);
        String propFile = getBaseDir() + "/fileLockSerialized.lock.db";
        SortedProperties p = SortedProperties.loadProperties(propFile);
        p.setProperty("changePending", "true");
        p.setProperty("modificationDataId", "1000");
        OutputStream out = IOUtils.openFileOutputStream(propFile, false);
        try {
            p.store(out, "test");
        } finally {
            out.close();
        }
        Thread.sleep(100);
        stat.execute("select * from test");
        conn.close();
    }
View Full Code Here

  public InputStream createInputStream(final long start) {
    return createInputStream(start, -1);
  }
 
  public OutputStream createOutputStream() {
    return new OutputStream() {
     
      @Override
      public void write(int b) throws IOException {
        throw new UnsupportedOperationException("buffered reading must be used"); //$NON-NLS-1$
      }
View Full Code Here

        testPipe();
        deleteDb("csv");
    }

    private void testPreserveWhitespace() throws Exception {
        OutputStream out = IOUtils.openFileOutputStream(getBaseDir() + "/test.tsv", false);
        out.write("a,b\n 1 , 2 \n".getBytes());
        out.close();
        Connection conn = getConnection("csv");
        Statement stat = conn.createStatement();
        ResultSet rs;
        rs = stat.executeQuery("select * from csvread('" + getBaseDir() + "/test.tsv')");
        rs.next();
View Full Code Here

        assertEquals(" 2 ", rs.getString(2));
        conn.close();
    }

    private void testChangeData() throws Exception {
        OutputStream out = IOUtils.openFileOutputStream(getBaseDir() + "/test.tsv", false);
        out.write("a,b,c,d,e,f,g\n1".getBytes());
        out.close();
        Connection conn = getConnection("csv");
        Statement stat = conn.createStatement();
        ResultSet rs = stat.executeQuery("select * from csvread('" + getBaseDir() + "/test.tsv')");
        assertEquals(7, rs.getMetaData().getColumnCount());
        assertEquals("A", rs.getMetaData().getColumnLabel(1));
        rs.next();
        assertEquals(1, rs.getInt(1));
        out = IOUtils.openFileOutputStream(getBaseDir() + "/test.tsv", false);
        out.write("x".getBytes());
        out.close();
        rs = stat.executeQuery("select * from csvread('" + getBaseDir() + "/test.tsv')");
        assertEquals(1, rs.getMetaData().getColumnCount());
        assertEquals("X", rs.getMetaData().getColumnLabel(1));
        assertFalse(rs.next());
        conn.close();
View Full Code Here

            }
            return new SQLXMLInputStreamFactory((SQLXML)lob).getInputStream();
        }         
      };
      InputStream is = isf.getInputStream();
      OutputStream fsos = store.createOutputStream();
      length = ObjectConverterUtil.write(fsos, is, bytes, -1);
    } catch (IOException e) {
      throw new TeiidComponentException(e);
    }
   
View Full Code Here

    }

    private static PrintStream getSummaryStream(String outputDir,
      String summaryName) throws IOException {
  File summaryFile = createSummaryFile(outputDir, summaryName);
  OutputStream os = new FileOutputStream(summaryFile);
  os = new BufferedOutputStream(os);
  return new PrintStream(os);
    }
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.