Java File Read via ByteBuffer readFileDataIntoBufferBE(FileChannel fc, final int size)

Here you can find the source of readFileDataIntoBufferBE(FileChannel fc, final int size)

Description

read File Data Into Buffer BE

License

Open Source License

Declaration

public static ByteBuffer readFileDataIntoBufferBE(FileChannel fc, final int size) throws IOException 

Method Source Code

//package com.java2s;
/*/*  ww  w. jav a 2  s. c o  m*/
 * Copyright (c) 2017 Eric A. Snell
 *
 * This file is part of eAlvaTag.
 *
 * eAlvaTag is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser
 * General Public License as published by the Free Software Foundation, either version 3 of the License,
 * or (at your option) any later version.
 *
 * eAlvaTag 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with eAlvaTag.  If not,
 * see <http://www.gnu.org/licenses/>.
 */

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.FileChannel;

public class Main {
    public static ByteBuffer readFileDataIntoBufferBE(FileChannel fc, final int size) throws IOException {
        final ByteBuffer tagBuffer = ByteBuffer.allocateDirect(size);
        fc.read(tagBuffer);
        tagBuffer.position(0);
        tagBuffer.order(ByteOrder.BIG_ENDIAN);
        return tagBuffer;
    }
}

Related

  1. readFileAsByteArray(File file)
  2. readFileAsByteArray(String path)
  3. readFileAsStringArray(File file)
  4. readFileChannelFully(FileChannel fileChannel, byte buf[], int off, int len)
  5. readFileChannelFully(FileChannel fileChannel, byte buf[], int off, int len)
  6. readFileFragment(FileChannel fc, long pos, int size)
  7. readFileHeader(FileInputStream fpi)
  8. readFileIntoString(File localFile)
  9. readFileIntoString(String path)