Is it possible to create an in-memory File object in Java? -
one of optimization projects i'm working on right makes extensive use of epanet. make repeated calls 2 simulation methods in epanet understand how water flows through water distribution network.
hydraulicsim 1 of classes make use of. 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 use qualitysim. here, use overloaded simulate methods:
public void simulate(file hydfile, file qualfile) throws ioexception, enexception { ... } void simulate(file hydfile, outputstream out) throws ioexception, enexception { ... } here's we're doing:
- create 2
fileobjects,hydfile,qualfile. - call
hydraulicsim.simulateonhydfile. - call
qualitysim.simulateonhydfile,qualfile. - delete files.
the problem have a lot of times. large problem, can hundreds of thousands or millions of times. can imagine slowdown repeatedly creating/writing/deleting these files causes.
so question this: possible me create these files reside in memory , never touch disk? each file small (i'm talking few hundred bytes), throwing them memory won't problem; need figure out how. searched around , didn't find much, save mappedbytebuffer, i'm not sure how, or if it's possible, create file class.
any advice welcome!
it might worth submit issue epanet team. simulate methods use file objects obtain input , output streams. if provided qualitysim.simulate method took streams params (which output stream not input stream) bypass fs. or fork , yourself.
Comments
Post a Comment