public String getContentEncoding() { try { return content.getContentInfo().getContentEncoding(); } catch (FileSystemException e) { throw new RuntimeException(e.getMessage()); } }
public Object execute(final CommandContext context) throws Exception { assert context != null; IO io = context.getIo(); // // TODO: Support multi-path cat, and the special '-' token (which is the default if no paths are given) // FileObject file = resolveFile(context, path); ensureFileExists(file); ensureFileHasContent(file); FileContent content = file.getContent(); FileContentInfo info = content.getContentInfo(); log.debug("Content type: {}", info.getContentType()); log.debug("Content encoding: {}", info.getContentEncoding()); // // TODO: Only cat files which we think are text, or warn if its not, allow flag to force // log.debug("Displaying file: {}", file.getName()); BufferedReader reader = new BufferedReader(new InputStreamReader(content.getInputStream())); try { cat(reader, io); } finally { Closer.close(reader); } FileObjects.close(file); return CommandAction.Result.SUCCESS; }
public Object execute(final CommandContext context) throws Exception { assert context != null; IO io = context.getIo(); // // TODO: Support multi-path cat, and the special '-' token (which is the default if no paths are given) // FileObject file = resolveFile(context, path); new FileObjectAssert(file).exists(); ensureFileHasContent(file); org.apache.commons.vfs.FileContent content = file.getContent(); FileContentInfo info = content.getContentInfo(); log.debug("Content type: {}", info.getContentType()); log.debug("Content encoding: {}", info.getContentEncoding()); // // TODO: Only cat files which we think are text, or warn if its not, allow flag to force // log.debug("Displaying file: {}", file.getName()); BufferedReader reader = new BufferedReader(new InputStreamReader(content.getInputStream())); try { cat(reader, io); } finally { Closer.close(reader); } FileObjects.close(file); return Result.SUCCESS; }
FileContentInfo contentInfo = content.getContentInfo(); io.info("Content type: {}", contentInfo.getContentType()); io.info("Content encoding: {}", contentInfo.getContentEncoding());
FileContentInfo contentInfo = content.getContentInfo(); io.info("Content type: {}", contentInfo.getContentType()); io.info("Content encoding: {}", contentInfo.getContentEncoding());