public static Charset guessEncoding( FileObject file, int bufferLength ) throws FileNotFoundException, IOException { return guessEncoding( new File( file.getName().getPathDecoded() ), bufferLength ); }
/** * Get a FileInputStream for a local file. Local files can be read with NIO. * * @param fileObject * @return a FileInputStream * @throws IOException * @deprecated because of API change in Apache VFS. As a workaround use FileObject.getName().getPathDecoded(); Then * use a regular File() object to create a File Input stream. */ @Deprecated public static FileInputStream getFileInputStream( FileObject fileObject ) throws IOException { if ( !( fileObject instanceof LocalFile ) ) { // We can only use NIO on local files at the moment, so that's what we limit ourselves to. // throw new IOException( BaseMessages.getString( PKG, "FixedInput.Log.OnlyLocalFilesAreSupported" ) ); } return new FileInputStream( fileObject.getName().getPathDecoded() ); }
FileInputStream in = null; try { in = new FileInputStream( file.getName().getPathDecoded() ); while ( in.available() > 0 ) { int b = in.read();
public static String guessEncodingName( FileObject file ) throws FileNotFoundException, IOException { return guessEncodingName( new File( file.getName().getPathDecoded() ) ); }
/** * Get the file input stream for a certain appender. * The appender is looked up using the filename * @param filename The exact filename (with path: c:\temp\logfile.txt) or just a filename (spoon.log) * @param exact true if this is the exact filename or just the last part of the complete path. * @return The file input stream of the appender * @throws IOException in case the appender ocan't be found */ public FileInputStream getFileInputStream( String filename, boolean exact ) throws IOException { Appender appender = pentahoLogger.getAppender( createFileAppenderName( filename, exact ) ); if ( appender == null ) { throw new IOException( "Unable to find appender for file: " + filename + " (exact=" + exact + ")" ); } return new FileInputStream( ( (Log4jFileAppender) appender ).getFile().getName().getPathDecoded() ); }
data.file.getName().getPathDecoded();
@Override public String getPathDecoded() throws FileSystemException { return fileName.getPathDecoded(); }
/** * This is an over simplistic implementation for VFS-437. */ private boolean isCircular(final FileObject linkDest) throws FileSystemException { return linkDest.getName().getPathDecoded().equals(this.getName().getPathDecoded()); }
/** * Attaches this file object to its file resource. */ @Override protected void doAttach() throws Exception { if (file == null) { // Remove the "file:///" // LocalFileName localFileName = (LocalFileName) getName(); final String fileName = rootFile + getName().getPathDecoded(); // fileName = UriParser.decode(fileName); file = new File(fileName); } }
/** * Attaches this file object to its file resource. */ @Override protected void doAttach() throws Exception { if (file == null) { // Remove the "file:///" // LocalFileName localFileName = (LocalFileName) getName(); final String fileName = rootFile + getName().getPathDecoded(); // fileName = UriParser.decode(fileName); file = new File(fileName); } }
/** * This is an over simplistic implementation for VFS-437. */ private boolean isCircular(final FileObject linkDest) throws FileSystemException { return linkDest.getName().getPathDecoded().equals(this.getName().getPathDecoded()); }
/** * Attaches this file object to its file resource. */ @Override protected void doAttach() throws Exception { if (file == null) { // Remove the "file:///" // LocalFileName localFileName = (LocalFileName) getName(); final String fileName = rootFile + getName().getPathDecoded(); // fileName = UriParser.decode(fileName); file = new File(fileName); } }
/** * This is an over simplistic implementation for VFS-437. */ private boolean isCircular(final FileObject linkDest) throws FileSystemException { return linkDest.getName().getPathDecoded().equals(this.getName().getPathDecoded()); }
/** * Attaches this file object to its file resource. */ @Override protected void doAttach() throws Exception { if (file == null) { // Remove the "file:///" // LocalFileName localFileName = (LocalFileName) getName(); final String fileName = rootFile + getName().getPathDecoded(); // fileName = UriParser.decode(fileName); file = new File(fileName); } }
protected void doRename(FileObject newfile) throws Exception { final SftpClient sftp = fs.getClient(); try { String oldName = getName().getPathDecoded(); String newName = newfile.getName().getPathDecoded(); if (oldName.equals(newName)) { throw new FileSystemException( "vfs.provider.sftp/rename-identical-files", new Object[] { newName }); } sftp.rename(oldName, newName); } finally { fs.putClient(sftp); } }
private void statSelf() throws Exception { final SftpClient sftp = fs.getClient(); try { attrs = sftp.stat(getName().getPathDecoded()); } catch (final SshException e) { // Does not exist attrs = null; } finally { fs.putClient(sftp); } }
protected void doDelete() throws Exception { final SftpClient sftp = fs.getClient(); try { if (FileType.FOLDER.equals(getType())) { sftp.rmdir(getName().getPathDecoded()); } else { sftp.rm(getName().getPathDecoded()); } } finally { fs.putClient(sftp); } }
protected void doCreateFolder() throws Exception { final SftpClient sftp = fs.getClient(); try { sftp.mkdir(getName().getPathDecoded(), -1); statSelf(); } finally { fs.putClient(sftp); } }
protected boolean doSetLastModifiedTime(final long modtime) throws Exception { final SftpClient sftp = fs.getClient(); try { sftp.setLastModified(getName().getPathDecoded(), modtime); statSelf(); return true; } finally { fs.putClient(sftp); } }
/** * Creates an input stream to read the file content from. The input stream is starting at the given position in the * file. */ InputStream getInputStream(final long filePointer) throws IOException { final ChannelSftp channel = getAbstractFileSystem().getChannel(); // Using InputStream directly from the channel // is much faster than the memory method. try { final InputStream is = channel.get(getName().getPathDecoded(), null, filePointer); return new SftpInputStream(channel, is); } catch (final SftpException e) { getAbstractFileSystem().putChannel(channel); throw new FileSystemException(e); } }