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 System.err.println("DDD: "+MirConfig.getProp("Home")+"content-types.properties");
34 fileNameMap = sun.net.www.MimeTable.loadTable();
35 producerStorageRoot = MirConfig.getProp("Producer.StorageRoot");
39 * Privater Konstruktor, um versehentliche Instantiierung zu verhindern
44 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 exception) {}
65 public static boolean read(String filename, byte out[]) {
68 f = new File(filename);
72 if (out.length != f.length())
74 FileInputStream inStream;
75 inStream = new FileInputStream(f);
78 } catch(IOException exception) {
87 public static long getSize(String filename) {
89 f = new File(filename);
99 private static FileNameMap getFileNameMap() {
100 if ((fileNameMap == null) && !fileNameMapLoaded) {
101 fileNameMap = sun.net.www.MimeTable.loadTable();
102 fileNameMapLoaded = true;
105 return new FileNameMap() {
106 private FileNameMap map = fileNameMap;
107 public String getContentTypeFor(String fileName) {
108 return map.getContentTypeFor(fileName);
113 public static void setFileNameMap(FileNameMap map) {
117 public static String guessContentTypeFromName(String fname) {
118 String contentType = null;
120 System.err.println("NAME: "+fname);
121 contentType = getFileNameMap().getContentTypeFor(fname);
122 System.err.println("TYPE: "+contentType);