Create DBEntry using AL5 URI with path parameterΒΆ
This example focuses on creating DBEntry using explicit path
See also
API documentation for imas.open
Caution
the LowLevel.FORCE_CREATE_PULSE mode is used to create an entry.
Remember: it overwrites existing entry!
public static void createDBEntryURIwithPath() throws Exception {
int entry = 0;
// example usage of uri with 'path' keyword pointing to relative location
try {
entry = imas.open("imas:mdsplus?path=./testdb_mdsplus", LowLevel.FORCE_CREATE_PULSE);
System.out.println("\nContent of testdb_mdsplus:");
Stream<Path> stream = Files.list(Paths.get("./testdb_mdsplus"));
stream.forEach(System.out::println);
// Content of testdb_mdsplus:
// ./testdb_mdsplus/ids_001.tree
// ./testdb_mdsplus/ids_001.characteristics
// ./testdb_mdsplus/ids_001.datafile
} catch (Exception e) {
System.err.println("\nFailed to open DBEntry with path\n" + e.getMessage());
throw e;
} finally {
imas.close(entry);
}
// example usage of uri with 'path' keyword pointing to relative location
try {
entry = imas.open("imas:hdf5?path=./testdb_hdf5", LowLevel.FORCE_CREATE_PULSE);
System.out.println("\nContent of testdb_hdf5:");
Stream<Path> stream = Files.list(Paths.get("./testdb_hdf5"));
stream.forEach(System.out::println);
// Content of testdb_hdf5:
// ./testdb_hdf5/master.h5
} catch (Exception e) {
System.err.println("\nFailed to open DBEntry with path\n" + e.getMessage());
throw e;
} finally {
imas.close(entry);
}
// example usage of uri with 'path' keyword pointing to relative location
try {
entry = imas.open("imas:ascii?path=./testdb_ascii", LowLevel.FORCE_CREATE_PULSE);
System.out.println("\nContent of testdb_ascii:");
Stream<Path> stream = Files.list(Paths.get("./testdb_ascii"));
stream.forEach(System.out::println);
// Content of testdb_ascii:
} catch (Exception e) {
System.err.println("\nFailed to open DBEntry with path\n" + e.getMessage());
throw e;
} finally {
imas.close(entry);
}
}
}
Output
javac -cp $CLASSPATH:. imasjava/examples/TestNewExamples.java ; java -cp $CLASSPATH:. imasjava.examples.TestNewExamples
Running OpenDatabase example case
Content of testdb_mdsplus:
./testdb_mdsplus/ids_001.characteristics
./testdb_mdsplus/ids_001.datafile
./testdb_mdsplus/ids_001.tree
Content of testdb_hdf5:
./testdb_hdf5/master.h5
Content of testdb_ascii: