3 * put your module comment here
13 import freemarker.template.*;
16 import javax.servlet.http.*;
20 * Hilfsklasse zum Mergen von Template und Daten
22 public final class FileUtil {
24 private static boolean fileNameMapLoaded = false;
25 private static FileNameMap fileNameMap;
26 private static String producerStorageRoot;
32 System.setProperty("content.types.user.table", MirConfig.getProp("Home")+"content-types.properties");
33 fileNameMap = sun.net.www.MimeTable.loadTable();
34 producerStorageRoot = MirConfig.getProp("Producer.StorageRoot");
38 * Privater Konstruktor, um versehentliche Instantiierung zu verhindern
43 public static boolean write(String filename, byte[] in)
46 boolean retVal = false;
51 f = new File(filename);
52 File dir = new File(f.getParent());
55 FileOutputStream outStream;
56 outStream = new FileOutputStream(f);
60 } catch(IOException e) {
61 throw new IOException(e.toString());
67 public static boolean read(String filename, byte out[])
71 f = new File(filename);
75 if (out.length != f.length())
77 FileInputStream inStream;
78 inStream = new FileInputStream(f);
81 } catch(IOException e) {
82 throw new IOException(e.toString());
90 public static long getSize(String filename) {
92 f = new File(filename);
102 private static FileNameMap getFileNameMap() {
103 if ((fileNameMap == null) && !fileNameMapLoaded) {
104 fileNameMap = sun.net.www.MimeTable.loadTable();
105 fileNameMapLoaded = true;
108 return new FileNameMap() {
109 private FileNameMap map = fileNameMap;
110 public String getContentTypeFor(String fileName) {
111 return map.getContentTypeFor(fileName);
116 public static void setFileNameMap(FileNameMap map) {
120 public static String guessContentTypeFromName(String fname) {
121 String contentType = null;
123 contentType = getFileNameMap().getContentTypeFor(fname);