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:

  1. create 2 file objects, hydfile , qualfile.
  2. call hydraulicsim.simulate on hydfile.
  3. call qualitysim.simulate on hydfile , qualfile.
  4. 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

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -