One of the optimization projects I'm currently working on is using EPANet extensively . We repeatedly turn to the two modeling methods in EPANet to understand how water flows through a water distribution network.
HydraulicSim is one of the classes we use. See Overloaded simulate methods:
public void simulate(File hyd) throws ENException { ... } public void simulate(OutputStream out) throws ENException, IOException { ... } public void simulate(DataOutput out) throws ENException, IOException { ... }
The other class we use is QualitySim . Here we also use the overloaded simulate methods:
public void simulate(File hydFile, File qualFile) throws IOException, ENException { ... } void simulate(File hydFile, OutputStream out) throws IOException, ENException { ... }
Here is what we are doing now:
- Create two
File objects, hydFile and qualFile . - Call
HydraulicSim.simulate on hydFile . - Call
QualitySim.simulate on hydFile and qualFile . - Delete files.
The problem is that we have to do this many times. For a big problem, we can do this hundreds of thousands or even millions of times. You can imagine that the slowdown is repeated when creating / writing / deleting these files.
So my question is this: is it possible to create these files so that they are only in memory and never touch the disk? Each file is very small (I say a few hundred bytes), so throwing them into memory will not be a problem; I just need to figure out how to do this. I searched around and didn't really find much except for MappedByteBuffer , but I'm not sure how and if possible to create a File from this class.
Any advice is appreciated!
java
Geoff
source share