FilterOutputStream close - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for FilterOutputStream close method.

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: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: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:writeInt, close
            // Tell the Zygote what our actual PID is (since it only knows about the 
            // wrapper that it directly forked). 
            if (fdNum != 0) {
                try { 
                    FileDescriptor fd = ZygoteInit.createFileDescriptor(fdNum);
                    DataOutputStream os = new DataOutputStream(new FileOutputStream(fd));
                    os.writeInt(Process.myPid());
                    os.close();
                    IoUtils.closeQuietly(fd);
                } catch (IOException ex) {
                    Slog.d(TAG, "Could not write pid of wrapped process to Zygote pipe.", ex);
                } 
            } 
 
            // Mimic Zygote preloading. 
            ZygoteInit.preload(); 
 
            // Launch the application. 
            String[] runtimeArgs = new String[args.length - 2];
            System.arraycopy(args, 2, runtimeArgs, 0, runtimeArgs.length);
7
CodeRank
This code example shows how to use the following methods:writeBytes, close
  } 
 
  static Path writeFile(FileSystem fs, Path f) throws IOException {
    DataOutputStream out = fs.create(f);
    try { 
      out.writeBytes("umamahesh: " + f);
    } finally { 
      out.close();
    } 
    assertTrue(fs.exists(f));
    return f;
  } 
 
} 
7
CodeRank
This code example shows how to use the following methods:writeInt, writeLong, close
    } 
 
    // Write the given metrics to the new state file 
    private void writeBackupState(long fileSize, long crc, ParcelFileDescriptor stateFile)
            throws IOException { 
        DataOutputStream out = new DataOutputStream(
                new FileOutputStream(stateFile.getFileDescriptor()));
        try { 
            out.writeLong(fileSize);
            out.writeLong(crc);
            out.writeInt(BACKUP_AGENT_VERSION);
        } finally { 
            if (out != null) {
                out.close();
            } 
        } 
    } 
} 
7
CodeRank

Related FilterOutputStream close Questions & Answers:

close Method Overview
Closes this output stream and releases any system resources associated with the stream.
See Code Examples for other Java 8 FilterOutputStream Methods: