Java File Read via ByteBuffer readAndTransfer(final String dir)

Here you can find the source of readAndTransfer(final String dir)

Description

read And Transfer

License

Open Source License

Declaration

public static void readAndTransfer(final String dir) 

Method Source Code


//package com.java2s;

import java.io.File;
import java.io.FileInputStream;

import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.SocketChannel;

public class Main {
    public static void readAndTransfer(final String dir) {
        File file = new File(dir);

        try (FileInputStream fis = new FileInputStream(file)) {
            FileChannel fc = fis.getChannel();
            ByteBuffer bb = ByteBuffer.allocate(1024);

            SocketChannel sc = null;
            while (fc.read(bb) != -1) {

            }//w  w  w.  j  a v  a2  s  .co m

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Related

  1. read(Path file, int pos, int length)
  2. read(Reader reader)
  3. read24BitInteger(byte[] threeBytes, ByteOrder order)
  4. read_file(File input)
  5. readAiffHeader(DataInputStream inStrm, FileChannel fc)
  6. readAsByteArray(final InputStream source)
  7. readBigEndianWord(byte[] buf)
  8. readBinaryFile(File file)
  9. readBinaryFileAsFloats(String fileName)