MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / openAsByteBuffer

Method openAsByteBuffer

ij/src/main/java/ij/IJ.java:2366–2392  ·  view source on GitHub ↗
(String path)

Source from the content-addressed store, hash-verified

2364 }
2365
2366 public static ByteBuffer openAsByteBuffer(String path) {
2367 if (path==null || path.equals("")) {
2368 OpenDialog od = new OpenDialog("Open as ByteBuffer", "");
2369 String directory = od.getDirectory();
2370 String name = od.getFileName();
2371 if (name==null) return null;
2372 path = directory + name;
2373 }
2374 File file = new File(path);
2375 if (!file.exists()) {
2376 error("OpenAsByteBuffer", "File not found");
2377 return null;
2378 }
2379 int len = (int)file.length();
2380 byte[] buffer = new byte[len];
2381 try {
2382 InputStream in = new BufferedInputStream(new FileInputStream(path));
2383 DataInputStream dis = new DataInputStream(in);
2384 dis.readFully(buffer);
2385 dis.close();
2386 }
2387 catch (Exception e) {
2388 error("OpenAsByteBuffer", e.getMessage());
2389 return null;
2390 }
2391 return ByteBuffer.wrap(buffer);
2392 }
2393
2394 /** Creates a new image.
2395 * @param title image name

Callers

nothing calls this directly

Calls 10

getDirectoryMethod · 0.95
getFileNameMethod · 0.95
errorMethod · 0.95
lengthMethod · 0.65
readFullyMethod · 0.65
closeMethod · 0.65
equalsMethod · 0.45
existsMethod · 0.45
getMessageMethod · 0.45
wrapMethod · 0.45

Tested by

no test coverage detected