1 package net.jaekl.qd.util;
4 import java.io.FileInputStream;
5 import java.io.FileNotFoundException;
6 import java.io.FileOutputStream;
7 import java.io.InputStream;
8 import java.io.OutputStream;
10 // Dispatch File Input/Output operations from a singleton
11 // This makes it possible to intercept file reads and writes
12 // during unit testing, and replace them with mock operations.
15 // Note: need volatile to implement double-checked locking in getInst()
16 static volatile FileIO m_inst = null;
20 public static FileIO getInst() {
21 FileIO result = m_inst;
23 synchronized(FileIO.class) {
25 m_inst = new FileIO();
33 public InputStream openInput(File file) throws FileNotFoundException
35 return new FileInputStream(file);
38 public OutputStream openOutput(File file) throws FileNotFoundException
40 return new FileOutputStream(file);