Package java.io

Examples of java.io.FileInputStream.available()


    public BigInteger getHighestSerialNumber() throws CertificateStoreException{
        if(highestSerialNumber == null) {
            // Value has not been cached.  Read from the disk.
            try {
                FileInputStream finp = new FileInputStream(highestSerialFile);
                byte[] data = new byte[finp.available()];
                finp.read(data);
                finp.close();
                highestSerialNumber = new BigInteger(new String(data).trim());
            } catch (Exception e) {
                throw new CertificateStoreException("Error while getting serial number.", e);
View Full Code Here


     * @param id Id of the certificate request.
     */
    public String getRequest(String id) {
        try {
            FileInputStream fin = new FileInputStream(new File(dir, id+CERT_REQ_FILE_SUFFIX));
            byte[] data = new byte[fin.available()];
            fin.read(data);
            fin.close();
            return new String(data);
        } catch (Exception e) {
            log.error("Error reading CSR. id = "+id, e);
View Full Code Here

                    if( logger.isDebugEnabled())
                        logger.debug("Reading in context state from file");

                    FileInputStream f_in = new FileInputStream(f);

                    if( f_in.available() > 0 )
                    {
                        ObjectInputStream in = new ObjectInputStream(f_in);
                        n = (NamingContextImpl)in.readObject();
                        in.close();
                    }
View Full Code Here

                ClassLoader.getSystemResource("file.txt").getPath()
              )
            );
   
    try {
      fileInputStream.available(); // should throw IOException because stream will closed.
    } catch (IOException e) {
      assertTrue(true);
    }
  }
View Full Code Here

      {
         try
         {
            MavenXpp3Reader reader = new MavenXpp3Reader();
            FileInputStream stream = new FileInputStream(getUnderlyingResourceObject());
            if (stream.available() > 0)
            {
               currentModel = reader.read(stream);
            }
            stream.close();
View Full Code Here

            try {
               if (trace) {
                  log.tracef("Opening file in %s", file);
               }
               fileInStream = new FileInputStream(file);
               int sz = fileInStream.available();
               bis = new BufferedInputStream(fileInStream);
               objectOutput.writeObject(file.getName());
               objectOutput.writeInt(sz);

               while (sz > totalBytesRead) {
View Full Code Here

      HCatRecord rec = new DefaultHCatRecord();
      rec.readFields(inpStream);
      Assert.assertEquals(recs[i],rec);
    }

    Assert.assertEquals(fInStream.available(), 0);
    fInStream.close();

  }

  public void testCompareTo() {
View Full Code Here

    Path fnLocal = new Path(System.getProperty("test.concat.data", "/tmp"), fn);
    Path fnHDFS  = new Path(workDir, fn);
    localFs.copyFromLocalFile(fnLocal, fnHDFS);

    final FileInputStream in = new FileInputStream(fnLocal.toString());
    assertEquals("concat bytes available", 148, in.available());

    // should wrap all of this header-reading stuff in a running-CRC wrapper
    // (did so in BuiltInGzipDecompressor; see below)

    byte[] compressedBuf = new byte[256];
View Full Code Here

    // here's first pair of DecompressorStreams:
    final FileInputStream in1 = new FileInputStream(fnLocal1.toString());
    final FileInputStream in2 = new FileInputStream(fnLocal2.toString());
    assertEquals("concat bytes available", 2734, in1.available());
    assertEquals("concat bytes available", 3413, in2.available()); // w/hdr CRC

    CompressionInputStream cin2 = gzip.createInputStream(in2);
    LineReader in = new LineReader(cin2);
    Text out = new Text();
View Full Code Here

    // here's first pair of BlockDecompressorStreams:
    final FileInputStream in1 = new FileInputStream(fnLocal1.toString());
    final FileInputStream in2 = new FileInputStream(fnLocal2.toString());
    assertEquals("concat bytes available", 2567, in1.available());
    assertEquals("concat bytes available", 3056, in2.available());

/*
    // FIXME
    // The while-loop below dies at the beginning of the 2nd concatenated
    // member (after 17 lines successfully read) with:
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.