Package java.io

Examples of java.io.FileInputStream.skip()


      File file = new File(filename);
      if (file.length() > 0)
      {
        FileInputStream readingFile;
        readingFile = new FileInputStream(filename);
        readingFile.skip(file.length() - 1);
        lastByte = readingFile.read();
        readingFile.close();
      }
    }
    catch (Exception e)
View Full Code Here


                                    socket = activeWaitForConnection(_serverSocket);
                                }

                                fileInput = new FileInputStream(source);
                                if (startPos > 0)
                                    fileInput.skip(startPos);
                                ftp.notify(new FtpNotify<String>(FtpNotify.TYPE_STOR, ProgNotify.START, bTemp ? m_tempFileNames[0] : _target));
                                OutputStream outputStream = socket.getOutputStream();
                                int readed;
                                byte[] buf = new byte[m_bufSize];
                                while (!bAbort && (readed = fileInput.read(buf)) > 0)
View Full Code Here

        public byte[] cutFile(File file, long offSet, int size)
                throws IOException {
            FileInputStream fis = null;
            try {
                fis = new FileInputStream(file);
                fis.skip(offSet);
                byte[] tmp = new byte[size];
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                int l = fis.read(tmp);
                baos.write(tmp, 0, l);
                return baos.toByteArray();
View Full Code Here

    final FileInputStream fis = new FileInputStream(_file);
    int bytesRead = -100;
    try {
      if (_filePtr > 0)
        for (long i = 0; i < _filePtr; i += fis.skip(_filePtr - i)) {
        }

      bytesRead = fis.read(_buffer, _bufferSize, _buffer.length - _bufferSize);

      if (bytesRead < 0)
View Full Code Here

        //open the map-output file
        mapOutputIn = SecureIOUtils.openForRead(
            new File(mapOutputFileName.toUri().getPath()), runAsUserName, null);

        //seek to the correct offset for the reduce
        mapOutputIn.skip(info.startOffset);
        long rem = info.partLength;
        int len =
          mapOutputIn.read(buffer, 0, (int)Math.min(rem, MAX_BYTES_TO_READ));
        while (rem > 0 && len >= 0) {
          rem -= len;
View Full Code Here

        String result = null;
        final File file = new File(path + "/bin/start.boot");
        try {
            final FileInputStream is = new FileInputStream(file);
            try {
                is.skip(14);
                readstring(is);
                result = readstring(is);
            } finally {
                is.close();
            }
View Full Code Here

                    }
                }
            }

            FileInputStream is = new FileInputStream(file);
            is.skip(startFrom);

            int status = (startFrom == 0) ? HTTP_OK : HTTP_PARTIAL;
            tx.setHeader("Content-Length", "" + (length - startFrom));
            tx.setHeader("Content-Range", "" + startFrom + "-" + (length - 1) + "/" + length);
View Full Code Here

                    }
                }
            }

            FileInputStream fis = new FileInputStream(f);
            fis.skip(startFrom);
            Response r = new Response(HTTP_OK, mime, fis);
            r.addHeader("Content-length", "" + (f.length() - startFrom));
            r.addHeader("Content-range", "" + startFrom + "-" +
                (f.length() - 1) + "/" + f.length());
            return r;
View Full Code Here

    return ret;
  }

  private byte[] getFileData(int i, int length) throws IOException {
    InputStream in = new FileInputStream(exe);
    in.skip(i);
    byte[] ret = new byte[length];
    in.read(ret);
    in.close();
    return ret;
  }
View Full Code Here

     * @tests java.io.FileInputStream#skip(long)
     */
    public void test_skipNegativeArgumentJ() throws IOException {
        FileInputStream fis = new FileInputStream(fileName);
        try {
            fis.skip(-5);
            fail("IOException must be thrown if number of bytes to skip <0");
        } catch (IOException e) {
            // Expected IOException
        } finally {
            fis.close();
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.