01: package de.regnis.q.sequence.line;
02:
03: import java.io.File;
04: import java.io.IOException;
05:
06: /**
07: * @author Marc Strapetz
08: */
09: public class QSequenceLineSystemTempDirectoryFactory implements
10: QSequenceLineTempDirectoryFactory {
11:
12: // Fields =================================================================
13:
14: private File tempDirectory;
15:
16: // Setup ==================================================================
17:
18: public QSequenceLineSystemTempDirectoryFactory() {
19: }
20:
21: // Implemented ============================================================
22:
23: public File getTempDirectory() throws IOException {
24: if (tempDirectory == null) {
25: int tries = 0;
26: for (;;) {
27: try {
28: tempDirectory = File.createTempFile(
29: "q.sequence.line.", ".temp" + tries);
30: tempDirectory.delete();
31: break;
32: } catch (IOException ex) {
33: tries++;
34: if (tries > 100) {
35: throw ex;
36: }
37: }
38: }
39: }
40:
41: return tempDirectory;
42: }
43:
44: public void close() {
45: tempDirectory.delete();
46: }
47: }
|