Java 8 FilterInputStream - 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 FilterInputStream class.

This code example shows how to use the following methods:close
      DataInputStream in = null;
      try { 
        FileSystem fs = dirName.getFileSystem(conf);
        in = fs.open(new Path(dirName, BLOOM_FILE_NAME));
        bloomFilter = new DynamicBloomFilter();
        bloomFilter.readFields(in);
        in.close();
        in = null;
      } catch (IOException ioe) {
        LOG.warn("Can't open BloomFilter: " + ioe + " - fallback to MapFile.");
        bloomFilter = null;
      } finally { 
        IOUtils.closeStream(in);
      } 
    } 
     
    /** 
     * Checks if this MapFile has the indicated key. The membership test is 
     * performed using a Bloom filter, so the result has always non-zero 
     * probability of false positives. 
8
CodeRank
This code example shows how to use the following methods:readFully, close
            byte[] body = null;
            if (entity != null) {
                try { 
                    if (entity.getContentLength() > 0) {
                        body = new byte[(int) entity.getContentLength()];
                        DataInputStream dis = new DataInputStream(entity.getContent());
                        try { 
                            dis.readFully(body);
                        } finally { 
                            try { 
                                dis.close();
                            } catch (IOException e) {
                                Log.e(TAG, "Unexpected IOException.", e);
                            } 
                        } 
                    } 
                } finally { 
                    if (entity != null) {
                        entity.consumeContent();
                    } 
8
CodeRank
This code example shows how to use the following methods:decodeStream, readUTF, close
        BufferedInputStream b = null;
        DataInputStream d = null;
        try { 
            f = new FileInputStream(filePath);
            b = new BufferedInputStream(f, BUFSIZE);
            d = new DataInputStream(b);
            Uri uri = Uri.parse(d.readUTF());
            Bitmap thumb = BitmapFactory.decodeStream(d);
            setData(uri, thumb);
            d.close();
        } catch (IOException e) {
            return false; 
        } finally { 
            MenuHelper.closeSilently(f);
            MenuHelper.closeSilently(b);
            MenuHelper.closeSilently(d);
        } 
        return true; 
    } 
 
    public void updateDisplayIfNeeded() { 
8
CodeRank
This code example shows how to use the following methods:readInt, mark, reset
   * @param in Datainputstream of fsimage 
   * @return Filesystem layout version of fsimage represented by stream 
   * @throws IOException If problem reading from in 
   */ 
  private int findImageVersion(DataInputStream in) throws IOException {
    in.mark(42); // arbitrary amount, resetting immediately
 
    int version = in.readInt();
    in.reset();
 
    return version;
  } 
   
  /** 
   * Build command-line options and descriptions 
   */ 
  public static Options buildOptions() { 
    Options options = new Options();
 
    // Build in/output file arguments, which are required, but there is no  
8
CodeRank
This code example shows how to use the following methods:close
        finally 
        { 
            out.close();
        } 
 
        DataInputStream in = new DataInputStream(new ByteArrayInputStream(testData));
        BytesReadTracker tracker = new BytesReadTracker(in);
 
        try 
        { 
            // boolean = 1byte 
            boolean bool = tracker.readBoolean();
            assertTrue(bool);
            assertEquals(1, tracker.getBytesRead());
            // byte = 1byte 
            byte b = tracker.readByte();
            assertEquals(b, 0x1);
            assertEquals(2, tracker.getBytesRead());
            // char = 2byte 
            char c = tracker.readChar();

8
CodeRank
This code example shows how to use the following methods:readFully, available, close
  } 
 
  protected String readFully(InputStream input) {
    byte[] buffer;
    try { 
      DataInputStream dataInput = new DataInputStream(input);
      try { 
        buffer = new byte[dataInput.available()];
        dataInput.readFully(buffer);
        return new String(buffer, 0, buffer.length, "UTF-8");
      } finally { 
        dataInput.close();
      } 
    } catch (IOException e) {
      e.printStackTrace();
    } 
 
    return null; 
  } 
 
8
CodeRank
This code example shows how to use the following methods:readFully, close
 
    if (entity.getContentLength() < 0)
      throw new IOException("Unknown content length!");
 
    byte[] responseBytes            = new byte[(int)entity.getContentLength()];
    DataInputStream dataInputStream = new DataInputStream(entity.getContent());
    dataInputStream.readFully(responseBytes);
    dataInputStream.close();
 
    entity.consumeContent();
    return responseBytes;
  } 
 
  protected static class MmsConnectionParameters { 
    private final String mmsc;
    private final String proxy;
    private final String port;
 
    public MmsConnectionParameters(String mmsc, String proxy, String port) {
      this.mmsc  = mmsc;
8
CodeRank
This code example shows how to use the following methods:readUTF, close
    assertTrie(trie, output, false, true);
  } 
   
  static Trie loadTrie(Path path) throws IOException {
    Trie trie;
    DataInputStream is = new DataInputStream(new BufferedInputStream(
        Files.newInputStream(path)));
    String method = is.readUTF().toUpperCase(Locale.ROOT);
    if (method.indexOf('M') < 0) {
      trie = new Trie(is);
    } else { 
      trie = new MultiTrie(is);
    } 
    is.close();
    return trie;
  } 
   
  private static void assertTrie(Trie trie, Path file, boolean usefull,
      boolean storeorig) throws Exception {
    LineNumberReader in = new LineNumberReader(Files.newBufferedReader(file, StandardCharsets.UTF_8));
7
CodeRank
This code example shows how to use the following methods:close
    return tracker.getPos();
  } 
 
  @Override 
  public void close() throws IOException { 
    in.close();
  } 
 
  @Override 
  public long length() throws IOException { 
    // file size + size of both buffers 
    return inner.length();
  } 
 
  void setBytes(byte[] newBytes, int version) throws IOException {
    inner.setData(newBytes);
    tracker = new FSEditLogLoader.PositionTrackingInputStream(inner);
    in = new DataInputStream(tracker);
 
    this.version = version;
7
CodeRank
This code example shows how to use the following methods:close
   
  @Override 
  public void map(BytesWritable key, BytesWritable value,
      OutputCollector<Text, Text> output, Reporter reporter) throws IOException {
    ByteArrayInputStream bin = new ByteArrayInputStream(key.get(), 0, key.getSize());
    DataInputStream in = new DataInputStream(bin);
    Row row = new Row();
    row.readFields(in);
     
    lastRow = row;
     
    in.close();
  } 
 
  @Override 
  public void configure(JobConf job) {
    this.job = job;
  } 
 
  @Override 
7
CodeRank

Related Java 8 FilterInputStream Questions & Answers:

See Code Examples for Java 8 FilterInputStream Methods: