* @throws Exception
*/
public static WordprocessingMLPackage convert(
org.apache.commons.vfs.FileObject in) throws Exception {
LocalFile localCopy = null;
if (!(in instanceof LocalFile)) {
StringBuffer sb = new StringBuffer("file:///");
sb.append(System.getProperty("user.home"));
sb.append("/.docx4j/tmp/");
sb.append(in.getName().getBaseName());
String tmpPath = sb.toString().replace('\\', '/');
try {
localCopy = (LocalFile) VFS.getManager().resolveFile(tmpPath);
localCopy.copyFrom(in, new FileTypeSelector(FileType.FILE));
localCopy.close();
} catch (FileSystemException exc) {
exc.printStackTrace();
throw new Docx4JException(
"Could not create a temporary local copy", exc);
} finally {
if (localCopy != null) {
try {
localCopy.delete();
} catch (FileSystemException exc) {
exc.printStackTrace();
log.warn("Couldn't delete temporary file " + tmpPath);
}
}