de.matrixweb.vfs.wrapped.JavaFile Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vfs Show documentation
Show all versions of vfs Show documentation
VFS is a virtual file system wich features mounting of other filesystems
inside. This could be anything which is iterable in a tree-like structure.
package de.matrixweb.vfs.wrapped;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
/**
* @author markusw
*/
public class JavaFile implements WrappedSystem {
private final File file;
/**
* @param file
*/
public JavaFile(final File file) {
this.file = file;
}
/**
* @see de.matrixweb.vfs.wrapped.WrappedSystem#getName()
*/
@Override
public String getName() {
return this.file.getName();
}
/**
* @see de.matrixweb.vfs.wrapped.WrappedSystem#exists()
*/
@Override
public boolean exists() {
return this.file.exists();
}
/**
* @see de.matrixweb.vfs.wrapped.WrappedSystem#isDirectory()
*/
@Override
public boolean isDirectory() {
return this.file.isDirectory();
}
/**
* @see de.matrixweb.vfs.wrapped.WrappedSystem#list()
*/
@Override
public List list() {
final List list = new ArrayList();
for (final File child : this.file.listFiles()) {
list.add(new JavaFile(child));
}
return list;
}
/**
* @see de.matrixweb.vfs.wrapped.WrappedSystem#lastModified()
*/
@Override
public long lastModified() {
return this.file.lastModified();
}
/**
* @see de.matrixweb.vfs.wrapped.WrappedSystem#getInputStream()
*/
@Override
public InputStream getInputStream() throws IOException {
return new FileInputStream(this.file);
}
/**
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return this.file.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy