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) {
45 boolean retVal = false;
50 f = new File(filename);
51 File dir = new File(f.getParent());
54 FileOutputStream outStream;
55 outStream = new FileOutputStream(f);
59 } catch(IOException exception) {}
64 public static boolean read(String filename, byte out[]) {
67 f = new File(filename);
71 if (out.length != f.length())
73 FileInputStream inStream;
74 inStream = new FileInputStream(f);
77 } catch(IOException exception) {
86 public static long getSize(String filename) {
88 f = new File(filename);
98 private static FileNameMap getFileNameMap() {
99 if ((fileNameMap == null) && !fileNameMapLoaded) {
100 fileNameMap = sun.net.www.MimeTable.loadTable();
101 fileNameMapLoaded = true;
104 return new FileNameMap() {
105 private FileNameMap map = fileNameMap;
106 public String getContentTypeFor(String fileName) {
107 return map.getContentTypeFor(fileName);
112 public static void setFileNameMap(FileNameMap map) {
116 public static String guessContentTypeFromName(String fname) {
117 String contentType = null;
119 contentType = getFileNameMap().getContentTypeFor(fname);