Java 8 FilterOutputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 FilterOutputStream class.

This code example shows how to use the following methods:writeBoolean, writeByte, writeShort, close
        try { 
            messageOutputStream = channelAssociation.acquireChannelMessageOutputStream();
        } catch (Exception e) {
            throw EjbMessages.MESSAGES.failedToOpenMessageOutputStream(e);
        } 
        dataOutputStream = new DataOutputStream(messageOutputStream);
        try { 
            // write header 
            dataOutputStream.writeByte(HEADER_TX_INVOCATION_RESPONSE);
            // write invocation id 
            dataOutputStream.writeShort(invocationId);
            // write a "bit" to indicate that this message contains the XAResource status for a "prepare" 
            // invocation 
            dataOutputStream.writeBoolean(true);
            // write the XAResource status 
            PackedInteger.writePackedInteger(dataOutputStream, xaResourceStatusCode);
        } finally { 
            channelAssociation.releaseChannelMessageOutputStream(messageOutputStream);
            dataOutputStream.close();
        } 

9
CodeRank
This code example shows how to use the following methods:write, putNextEntry, close, closeEntry
    assertEquals("hello", IOUtils.toString(in));
  } 
   
  private File makeTestJar() throws IOException {
    File jarFile = new File(testDir, "test.jar");
    JarOutputStream out = new JarOutputStream(new FileOutputStream(jarFile));
    ZipEntry entry = new ZipEntry("resource.txt");
    out.putNextEntry(entry);
    out.write("hello".getBytes());
    out.closeEntry();
    out.close();
    return jarFile;
  } 
   
} 
9
CodeRank
This code example shows how to use the following methods:writeByte, writeShort, close
    public void testUnsignedRead() throws Exception 
    { 
        byte[] testData;
 
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream out = new DataOutputStream(baos);
        try 
        { 
            // byte 
            out.writeByte(0x1);
            // short 
            out.writeShort(1);
            testData = baos.toByteArray();
        } 
        finally 
        { 
            out.close();
        } 
 
        DataInputStream in = new DataInputStream(new ByteArrayInputStream(testData));

9
CodeRank
This code example shows how to use the following methods:close
  public final void write(DataOutput out) throws IOException {
    if (compressed == null) {
      ByteArrayOutputStream deflated = new ByteArrayOutputStream();
      Deflater deflater = new Deflater(Deflater.BEST_SPEED);
      DataOutputStream dout =
        new DataOutputStream(new DeflaterOutputStream(deflated, deflater));
      writeCompressed(dout);
      dout.close();
      deflater.end();
      compressed = deflated.toByteArray();
    } 
    out.writeInt(compressed.length);
    out.write(compressed);
  } 
 
  /** Subclasses implement this instead of {@link #write(DataOutput)}. */ 
  protected abstract void writeCompressed(DataOutput out) throws IOException;
 
} 
9
CodeRank
This code example shows how to use the following methods:close, write
    utilTest.checkUserDir();
    utilTest.redirectIfAntJunit();
  } 
 
  protected void createInput() throws IOException { 
    DataOutputStream out = new DataOutputStream(new FileOutputStream(INPUT_FILE.getAbsoluteFile()));
    out.write(input.getBytes("UTF-8"));
    out.close();
  } 
 
  protected String[] genArgs() {
    return new String[] {
      "-input", INPUT_FILE.getAbsolutePath(),
      "-output", OUTPUT_DIR.getAbsolutePath(),
      "-mapper", map,
      "-reducer", reduce,
      "-jobconf", "mapreduce.task.files.preserve.failedtasks=true", 
      "-jobconf", "stream.tmpdir="+System.getProperty("test.build.data","/tmp"),
      "-io", "typedbytes" 
    }; 
8
CodeRank
This code example shows how to use the following methods:flush, close
        File file = resourceLoader.find( directory, filename );
        if ( file == null ) {
            file = resourceLoader.createFile(directory, filename);
        } 
         
        BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
        try { 
            XStreamPersister xp = xpf.createXMLPersister();
            initXStreamPersister(xp, gs);
            xp.save( service, out );
             
            out.flush();
        } 
        finally { 
            out.close();
        } 
    } 
     
    /** 
     * Hook for subclasses to configure the xstream. 
8
CodeRank
This code example shows how to use the following methods:close, write
    utilTest.checkUserDir();
    utilTest.redirectIfAntJunit();
  } 
 
  protected void createInput() throws IOException { 
    DataOutputStream out = new DataOutputStream(new FileOutputStream(INPUT_FILE.getAbsoluteFile()));
    out.write(input.getBytes("UTF-8"));
    out.close();
  } 
 
  protected String[] genArgs() {
    return new String[] {
      "-input", INPUT_FILE.getAbsolutePath(),
      "-output", OUTPUT_DIR.getAbsolutePath(),
      "-mapper", map,
      "-reducer", reduce,
      "-jobconf", "mapreduce.task.files.preserve.failedtasks=true", 
      "-jobconf", "stream.tmpdir="+System.getProperty("test.build.data","/tmp"),
      "-jobconf", "stream.map.output=rawbytes", 
      "-jobconf", "stream.reduce.input=rawbytes", 
8
CodeRank
This code example shows how to use the following methods:close
    out.write(value.getData(), value.getPosition(), valueLength); 
  } 
 
  public void close() throws IOException { 
    // Write EOF_MARKER for key/value length 
    WritableUtils.writeVInt(out, IFile.EOF_MARKER);
    WritableUtils.writeVInt(out, IFile.EOF_MARKER);
     
    // Close the stream  
    out.close();
    out = null;
  } 
 
} 
8
CodeRank
This code example shows how to use the following methods:writeInt, writeLong, close, write
     */ 
    private static byte[] generateSeed() { 
        try { 
            ByteArrayOutputStream seedBuffer = new ByteArrayOutputStream();
            DataOutputStream seedBufferOut =
                    new DataOutputStream(seedBuffer);
            seedBufferOut.writeLong(System.currentTimeMillis());
            seedBufferOut.writeLong(System.nanoTime());
            seedBufferOut.writeInt(Process.myPid());
            seedBufferOut.writeInt(Process.myUid());
            seedBufferOut.write(BUILD_FINGERPRINT_AND_DEVICE_SERIAL);
            seedBufferOut.close();
            return seedBuffer.toByteArray();
        } catch (IOException e) {
            throw new SecurityException("Failed to generate seed", e);
        } 
    } 
 
    /** 
     * Gets the hardware serial number of this device. 
7
CodeRank
This code example shows how to use the following methods:flush, close
                _file = new File (_tmpDir, fileName);
 
                BufferedOutputStream bos = null;
                try 
                { 
                    bos = new BufferedOutputStream(new FileOutputStream(_file));
                    _bout.writeTo(bos);
                    bos.flush();
                } 
                finally 
                { 
                    if (bos != null)
                        bos.close();
                    _bout = null;
                } 
            } 
            else 
            { 
                //the part data is already written to a temporary file, just rename it 
                _temporary = false;
7
CodeRank

Related Java 8 FilterOutputStream Questions & Answers:

See Code Examples for Java 8 FilterOutputStream Methods: