Channels: newOutputStream(WritableByteChannel ch) : Channels « java.nio.channels « Java by API






Channels: newOutputStream(WritableByteChannel ch)

 
import java.io.File;
import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;

public class Main {
  public static void main(String[] argv) throws Exception {
    // Create a read/writeable file channel
    File file = new File("filename");
    FileChannel channel = new RandomAccessFile(file, "rw").getChannel();

    OutputStream os = Channels.newOutputStream(channel);
    os.close();
  }
}

   
  








Related examples in the same category

1.Channels: newInputStream(ReadableByteChannel ch)