1 16 package org.apache.commons.vfs.impl; 17 18 import org.apache.commons.vfs.FileContent; 19 import org.apache.commons.vfs.FileContentInfo; 20 import org.apache.commons.vfs.FileContentInfoFactory; 21 22 import java.net.FileNameMap ; 23 import java.net.URLConnection ; 24 25 32 public class FileContentInfoFilenameFactory implements FileContentInfoFactory 33 { 34 public FileContentInfo create(FileContent fileContent) 35 { 36 String contentType = null; 37 38 String name = fileContent.getFile().getName().getBaseName(); 39 if (name != null) 40 { 41 FileNameMap fileNameMap = URLConnection.getFileNameMap(); 42 contentType = fileNameMap.getContentTypeFor(name); 43 } 44 45 return new DefaultFileContentInfo(contentType, null); 46 } 47 } 48 | Popular Tags |