37 |
|
|
38 |
package java.nio.channels; |
package java.nio.channels; |
39 |
|
|
40 |
import java.io.*; |
import java.io.IOException; |
41 |
import java.nio.*; |
import java.nio.ByteBuffer; |
42 |
import java.nio.channels.spi.*; |
import java.nio.channels.spi.AbstractInterruptibleChannel; |
43 |
|
|
44 |
public abstract class FileChannel extends AbstractInterruptibleChannel |
public abstract class FileChannel extends AbstractInterruptibleChannel |
45 |
implements ByteChannel, GatheringByteChannel, ScatteringByteChannel |
implements ByteChannel, GatheringByteChannel, ScatteringByteChannel |
46 |
{ |
{ |
47 |
|
public static class MapMode |
48 |
|
{ |
49 |
|
public int m; |
50 |
|
|
51 |
|
public static MapMode READ_ONLY = new MapMode(0); |
52 |
|
public static MapMode READ_WRITE = new MapMode(1); |
53 |
|
public static MapMode PRIVATE = new MapMode(2); |
54 |
|
|
55 |
public int write(ByteBuffer[] srcs) throws IOException |
MapMode(int a) |
56 |
{ |
{ |
57 |
long p = write(srcs, 0, srcs.length); |
m = a; |
|
return (int) p; |
|
58 |
} |
} |
59 |
|
|
60 |
public static class MapMode |
public String toString() |
61 |
{ |
{ |
62 |
public int m; |
return ""+m; |
|
|
|
|
public static MapMode READ_ONLY = new MapMode(0); |
|
|
public static MapMode READ_WRITE = new MapMode(1); |
|
|
public static MapMode PRIVATE = new MapMode(2); |
|
|
|
|
|
MapMode(int a) |
|
|
{ |
|
|
m = a; |
|
|
} |
|
|
|
|
|
public String toString() |
|
|
{ |
|
|
return ""+m; |
|
|
} |
|
63 |
} |
} |
64 |
|
} |
65 |
|
|
66 |
public abstract MappedByteBuffer map(MapMode mode, |
protected FileChannel() |
67 |
long position, |
{ |
68 |
int size) |
} |
69 |
throws IOException; |
|
70 |
|
public abstract MappedByteBuffer map(MapMode mode, long position, int size) |
71 |
/** |
throws IOException; |
72 |
* Return the size of the file thus far |
|
73 |
*/ |
/** |
74 |
public abstract long size() throws IOException; |
* Return the size of the file thus far |
75 |
public abstract long write(ByteBuffer[] srcs, int offset, int length) throws IOException; |
*/ |
76 |
public abstract int read(ByteBuffer dst) throws IOException; |
public abstract long size() throws IOException; |
77 |
public abstract int write(ByteBuffer src) throws IOException; |
public abstract long write(ByteBuffer[] srcs, int offset, int length) |
78 |
protected abstract void implCloseChannel() throws IOException; |
throws IOException; |
79 |
|
public abstract int read(ByteBuffer dst) throws IOException; |
80 |
|
protected abstract void implCloseChannel() throws IOException; |
81 |
|
|
82 |
/* msync with the disk */ |
/* msync with the disk */ |
83 |
public abstract void force(boolean metaData); |
public abstract void force(boolean metaData); |
84 |
} |
} |
|
|
|