Package java.io

Examples of java.io.DataInputStream.readFully()


 
    private FetchedDatum makeFetchedDatum(URL path) throws IOException {
        File file = new File(path.getFile());
        byte[] bytes = new byte[(int) file.length()];
        DataInputStream in = new DataInputStream(new FileInputStream(file));
        in.readFully(bytes);

        String url = path.toExternalForm().toString();
        FetchedDatum fetchedDatum = new FetchedDatum(url, url, System.currentTimeMillis(), new HttpHeaders(), new ContentBytes(bytes), "text/html", 0);
        return fetchedDatum;
    }
View Full Code Here


        while (true) {
            try {
                final int time = data.readInt();
                final int dtLength = data.readUnsignedShort();
                final byte[] deviceToken = new byte[dtLength];
                data.readFully(deviceToken);

                result.put(deviceToken, time);
            } catch (final EOFException e) {
                break;
            } catch (final IOException e) {
View Full Code Here

      long read = 0;
      try {
        while (read < size) {
          long remains = size - read;
          int n = (remains<=buffer.length) ? (int)remains : buffer.length;
          in.readFully(buffer, 0, n);
          read += n;
          if (fastCheck) {
            Arrays.fill(check, (byte)random.nextInt(Byte.MAX_VALUE));
          } else {
            random.nextBytes(check);
View Full Code Here

      if(sz == 0)
        return false;
      is = new DataInputStream(data.getInputStream());
      byte[] buf = new byte[sz];
      // FIXME Fortunately firefox doesn't detect RSS in UTF16 etc ... yet
      is.readFully(buf);
      /**
     * Look for any of the following strings:
     * <rss
     * &lt;feed
     * &lt;rdf:RDF
 
View Full Code Here

    DataInputStream dis = null;
    try {
      is = part.getInputStream();
      dis = new DataInputStream(is);
      byte[] buf = new byte[(int)Math.min(part.size(), maxlength)];
      dis.readFully(buf);
      return buf;
    } catch (IOException ioe) {
           Logger.error(this, "Caught IOE:" + ioe.getMessage());
    } finally {
      Closer.close(dis);
View Full Code Here

    DataInputStream dis = null;
    try {
      is = part.getInputStream();
      dis = new DataInputStream(is);
      byte[] buf = new byte[(int)Math.min(part.size(), maxLength)];
      dis.readFully(buf, 0, buf.length);
      return buf;
    } catch (IOException ioe) {
           Logger.error(this, "Caught IOE:" + ioe.getMessage());
           return new byte[0];
    } finally {
View Full Code Here

        DataInputStream bIn = new DataInputStream(b);
        long checked = 0;
        while(checked < size) {
            int toRead = (int)Math.min(BUFFER_SIZE, size - checked);
            aIn.readFully(aBuffer, 0, toRead);
            bIn.readFully(bBuffer, 0, toRead);
            if(!MessageDigest.isEqual(aBuffer, bBuffer))
                return false;
            checked += toRead;
        }
        return true;
View Full Code Here

    long size = toReturn.size;
    byte[] buf = new byte[4096];
    while(written < size) {
      int toRead = (int) Math.min(buf.length, (size - written));
      try {
        dis.readFully(buf, 0, toRead);
      } catch (IOException e) {
        Logger.error(this, "Could not read bytes "+written+" to "+(written + toRead)+" from file "+toReturn.filename+" which is supposed to be "+size+" bytes ("+toReturn.filename.length()+ ')');
        return;
      }
      os.write(buf, 0, toRead);
View Full Code Here

  public void readFilter(InputStream input, OutputStream output, String charset, HashMap<String, String> otherParams,
      FilterCallback cb) throws DataFilterException, IOException {
    DataInputStream dis = new DataInputStream(input);
    dis.mark(54);
    byte[] StartWord = new byte[2];
    dis.readFully(StartWord);
    if((!Arrays.equals(StartWord, bmpHeaderwindows)) && (!Arrays.equals(StartWord, bmpHeaderos2bArray)) && (!Arrays.equals(StartWord, bmpHeaderos2cIcon)) && (!Arrays.equals(StartWord, bmpHeaderos2cPointer)) && (!Arrays.equals(StartWord, bmpHeaderos2Icon)) && (!Arrays.equals(StartWord, bmpHeaderos2Pointer))) {  //Checking the first word
      throwHeaderError(l10n("InvalidStartWordT"), l10n("InvalidStartWordD"));
    }

    int fileSize = readInt(dis); // read total file size
View Full Code Here

      throwHeaderError(l10n("InvalidStartWordT"), l10n("InvalidStartWordD"));
    }

    int fileSize = readInt(dis); // read total file size
    byte[] skipbytes=new byte[4];
    dis.readFully(skipbytes);
    int headerSize = readInt(dis); // read file header size or pixel offset
    if(headerSize<0) {
      throwHeaderError(l10n("InvalidOffsetT"), l10n("InvalidOffsetD"));
    }
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.