1 11 package org.eclipse.core.internal.runtime; 12 13 import java.io.*; 14 15 22 public class SafeFileInputStream extends FilterInputStream { 23 protected static final String EXTENSION = ".bak"; 25 public SafeFileInputStream(File file) throws IOException { 26 this(file.getAbsolutePath(), null); 27 } 28 29 public SafeFileInputStream(String targetName) throws IOException { 30 this(targetName, null); 31 } 32 33 36 public SafeFileInputStream(String targetPath, String tempPath) throws IOException { 37 super(getInputStream(targetPath, tempPath)); 38 } 39 40 private static InputStream getInputStream(String targetPath, String tempPath) throws IOException { 41 File target = new File(targetPath); 42 if (!target.exists()) { 43 if (tempPath == null) 44 tempPath = target.getAbsolutePath() + EXTENSION; 45 target = new File(tempPath); 46 } 47 return new BufferedInputStream(new FileInputStream(target)); 48 } 49 } | Popular Tags |