Java by API/java.nio/DoubleBuffer
Версия от 17:43, 31 мая 2010; (обсуждение)
Содержание
DoubleBuffer: get()
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
public class Main {
public static void main(String[] args) {
ByteBuffer bb = ByteBuffer.wrap(new byte[] { 0, 0, 0, 0, 0, 0, 0, "a" });
bb.rewind();
DoubleBuffer db = ((ByteBuffer) bb.rewind()).asDoubleBuffer();
System.out.println("Double Buffer");
while (db.hasRemaining())
System.out.println(db.position() + " -> " + db.get());
}
}
DoubleBuffer: hasRemaining()
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
public class Main {
public static void main(String[] args) {
ByteBuffer bb = ByteBuffer.wrap(new byte[] { 0, 0, 0, 0, 0, 0, 0, "a" });
bb.rewind();
DoubleBuffer db = ((ByteBuffer) bb.rewind()).asDoubleBuffer();
System.out.println("Double Buffer");
while (db.hasRemaining())
System.out.println(db.position() + " -> " + db.get());
}
}
DoubleBuffer: position()
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
public class Main {
public static void main(String[] args) {
ByteBuffer bb = ByteBuffer.wrap(new byte[] { 0, 0, 0, 0, 0, 0, 0, "a" });
bb.rewind();
DoubleBuffer db = ((ByteBuffer) bb.rewind()).asDoubleBuffer();
System.out.println("Double Buffer");
while (db.hasRemaining())
System.out.println(db.position() + " -> " + db.get());
}
}
DoubleBuffer: put(double d)
import java.nio.ByteBuffer;
public class Main {
private static final int BSIZE = 1024;
public static void main(String[] args) {
ByteBuffer bb = ByteBuffer.allocate(BSIZE);
bb.asDoubleBuffer().put(99471142);
System.out.println(bb.getDouble());
}
}