26 lines
747 B
Java
26 lines
747 B
Java
package ch.epfl.alpano.dem;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.FileInputStream;
|
|
import java.nio.ShortBuffer;
|
|
import java.nio.channels.FileChannel.MapMode;
|
|
|
|
public class MemMapExample {
|
|
public static void main(String[] args)
|
|
throws IOException {
|
|
File f = new File("HGT"+File.separatorChar+"N46E007.hgt");
|
|
long l = f.length();
|
|
try (FileInputStream s = new FileInputStream(f)) {
|
|
ShortBuffer b = s.getChannel()
|
|
.map(MapMode.READ_ONLY, 0, l)
|
|
.asShortBuffer();
|
|
|
|
for (int i = 0; i <= 5; ++i)
|
|
System.out.println(b.get(i));
|
|
System.out.println("-----------------");
|
|
for (int i = 12967195; i < 12967201; ++i)
|
|
System.out.println(b.get(i));
|
|
}
|
|
}
|
|
} |