Java ByteBuffer Put checkReadSpace(FileInputStream aStream, ByteBuffer aBuf)

Here you can find the source of checkReadSpace(FileInputStream aStream, ByteBuffer aBuf)

Description

check Read Space

License

Open Source License

Declaration

public static void checkReadSpace(FileInputStream aStream, ByteBuffer aBuf) throws IOException 

Method Source Code


//package com.java2s;
/*//ww w  .j  a v  a  2 s  .co m
Password Tracker (PATRA). An application to safely store your passwords.
Copyright (C) 2006-2009  Bruno Ranschaert, S.D.I.-Consulting BVBA.
    
For more information contact: nospam@sdi-consulting.com
Visit our website: http://www.sdi-consulting.com
    
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
    
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

import java.io.FileInputStream;

import java.io.IOException;
import java.nio.ByteBuffer;

public class Main {
    public static void checkReadSpace(FileInputStream aStream, ByteBuffer aBuf) throws IOException {
        if (aBuf.remaining() < 8) {
            aBuf.flip();
            aStream.getChannel().read(aBuf);
            aBuf.flip();
        }
    }
}

Related

  1. bufToStream(ByteBuffer b, OutputStream out)
  2. byteBufferToInputStream(final ByteBuffer byteBuffer)
  3. byteBufferToOutputStream(ByteBuffer in, OutputStream out)
  4. computeSize(ByteBuffer[] buffers)
  5. convert(Object lock, CharsetEncoder encoder, ByteBuffer bytes, CharBuffer chars, OutputStream out)
  6. deserializeString(ByteBuffer inputBuffer, Charset charset)
  7. extractString(ByteArrayOutputStream byteBuffer)