Java examples for File Path IO:File Channel
Creating a Stream from a Channel
import java.io.File; import java.io.IOException; import java.io.InputStream; 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) { try {/*from w w w . j a va 2 s .co m*/ // Create a read/writable file channel File file = new File("filename"); FileChannel channel = new RandomAccessFile(file, "rw").getChannel(); OutputStream os = Channels.newOutputStream(channel); InputStream is = Channels.newInputStream(channel); is.close(); System.out.println("done"); } catch (IOException e) { } } }