comparison servlet/src/digilib/io/FileOps.java @ 176:67ff8c7fecb9

Servlet version 1.17b2 - new mapping file for "virtual directories" - direct file URLs now work without extension (even with wrong ones)
author robcast
date Mon, 10 Nov 2003 20:59:00 +0100
parents e743b853efca
children afe7ff98bb71
comparison
equal deleted inserted replaced
175:633947100c86 176:67ff8c7fecb9
146 pathArray[i] = s + File.separator; 146 pathArray[i] = s + File.separator;
147 } 147 }
148 } 148 }
149 return pathArray; 149 return pathArray;
150 } 150 }
151
152 /** Extract the base of a file name (sans extension).
153 *
154 * Returns the filename without the extension. The extension is the part behind
155 * the last dot in the filename. If the filename has no dot the full file name
156 * is returned.
157 *
158 * @param fn
159 * @return
160 */
161 public static String basename(String fn) {
162 int i = fn.lastIndexOf('.');
163 if (i > 0) {
164 return fn.substring(0, i);
165 }
166 return fn;
167 }
168
169 /** Extract the extension of a file name.
170 *
171 * Returns the extension of a file name. The extension is the part behind
172 * the last dot in the filename. If the filename has no dot the empty string
173 * is returned.
174 *
175 * @param fn
176 * @return
177 */
178 public static String extname(String fn) {
179 int i = fn.lastIndexOf('.');
180 if (i > 0) {
181 return fn.substring(i+1);
182 }
183 return "";
184 }
151 185
152 /** 186 /**
153 * FileFilter for image types (helper class for getFile) 187 * FileFilter for image types (helper class for getFile)
154 */ 188 */
155 static class ImageFileFilter implements FileFilter { 189 static class ImageFileFilter implements FileFilter {