Package org.xwiki.velocity.tools.nio
Class NIOTool
- java.lang.Object
-
- org.xwiki.velocity.tools.nio.NIOTool
-
public class NIOTool extends Object
Provides access to some of the static NIO2 Files methods.- Since:
- 7.4M2
- Version:
- $Id: aa10ac341242c55ae56e0536210639fa47fe823a $
-
-
Constructor Summary
Constructors Constructor Description NIOTool()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
exists(Path path, LinkOption... options)
Object
getAttribute(Path path, String attribute, LinkOption... options)
FileTime
getLastModifiedTime(Path path, LinkOption... options)
boolean
isDirectory(Path path, LinkOption... options)
boolean
isReadable(Path path)
boolean
isRegularFile(Path path, LinkOption... options)
boolean
isSymbolicLink(Path path)
BufferedReader
newBufferedReader(Path path, Charset cs)
DirectoryStream<Path>
newDirectoryStream(Path dir)
DirectoryStream<Path>
newDirectoryStream(Path dir, String glob)
DirectoryStream<Path>
newDirectoryStream(Path dir, DirectoryStream.Filter filter)
byte[]
readAllBytes(Path path)
List<String>
readAllLines(Path path, Charset cs)
Map<String,Object>
readAttributes(Path path, String attributes, LinkOption... options)
long
size(Path path)
SeeFiles.size(Path)
.
-
-
-
Method Detail
-
newDirectoryStream
public DirectoryStream<Path> newDirectoryStream(Path dir)
SeeFiles.newDirectoryStream(Path)
.Velocity Example:
#set ($dirStream = $niotool.newDirectoryStream("attach:Sandbox.WebHome@vma.txt.zip/")) #foreach ($entry in $dirStream) * {{{$entry}}} #end
- Parameters:
dir
- SeeFiles.newDirectoryStream(Path)
- Returns:
- See
Files.newDirectoryStream(Path)
-
newDirectoryStream
public DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter filter)
- Parameters:
dir
- SeeFiles.newDirectoryStream(Path, DirectoryStream.Filter)
filter
- SeeFiles.newDirectoryStream(Path, DirectoryStream.Filter)
- Returns:
- See
Files.newDirectoryStream(Path, DirectoryStream.Filter)
-
newDirectoryStream
public DirectoryStream<Path> newDirectoryStream(Path dir, String glob)
- Parameters:
dir
- SeeFiles.newDirectoryStream(Path, String)
glob
- SeeFiles.newDirectoryStream(Path, String)
- Returns:
- See
Files.newDirectoryStream(Path, String)
-
isDirectory
public boolean isDirectory(Path path, LinkOption... options)
- Parameters:
path
- SeeFiles.isDirectory(Path, LinkOption...)
options
- SeeFiles.isDirectory(Path, LinkOption...)
- Returns:
- See
Files.isDirectory(Path, LinkOption...)
-
isRegularFile
public boolean isRegularFile(Path path, LinkOption... options)
- Parameters:
path
- SeeFiles.isRegularFile(Path, LinkOption...)
options
- SeeFiles.isRegularFile(Path, LinkOption...)
- Returns:
- See
Files.isRegularFile(Path, LinkOption...)
-
isReadable
public boolean isReadable(Path path)
- Parameters:
path
- SeeFiles.isReadable(Path)
- Returns:
- See
Files.isReadable(Path)
-
isSymbolicLink
public boolean isSymbolicLink(Path path)
- Parameters:
path
- SeeFiles.isSymbolicLink(Path)
- Returns:
- See
Files.isSymbolicLink(Path)
-
exists
public boolean exists(Path path, LinkOption... options)
- Parameters:
path
- SeeFiles.exists(Path, LinkOption...)
options
- SeeFiles.exists(Path, LinkOption...)
- Returns:
- See
Files.exists(Path, LinkOption...)
-
readAllBytes
public byte[] readAllBytes(Path path)
SeeFiles.readAllBytes(Path)
.Velocity Example:
$stringtool.toString($niotool.readAllBytes("attach:Sandbox.WebHome@vma.txt.zip/vma.txt"), "utf-8")
- Parameters:
path
- SeeFiles.readAllBytes(Path)
- Returns:
- See
Files.readAllBytes(Path)
-
readAllLines
public List<String> readAllLines(Path path, Charset cs)
- Parameters:
path
- SeeFiles.readAllLines(Path, Charset)
cs
- SeeFiles.readAllLines(Path, Charset)
- Returns:
- See
Files.readAllLines(Path, Charset)
-
newBufferedReader
public BufferedReader newBufferedReader(Path path, Charset cs)
- Parameters:
path
- SeeFiles.newBufferedReader(Path, Charset)
cs
- SeeFiles.newBufferedReader(Path, Charset)
- Returns:
- See
Files.newBufferedReader(Path, Charset)
-
size
public long size(Path path)
SeeFiles.size(Path)
.- Parameters:
path
- SeeFiles.size(Path)
- Returns:
- See
Files.size(Path)
-
getAttribute
public Object getAttribute(Path path, String attribute, LinkOption... options)
- Parameters:
path
- SeeFiles.getAttribute(Path, String, LinkOption...)
attribute
- SeeFiles.getAttribute(Path, String, LinkOption...)
options
- SeeFiles.getAttribute(Path, String, LinkOption...)
- Returns:
- See
Files.getAttribute(Path, String, LinkOption...)
-
readAttributes
public Map<String,Object> readAttributes(Path path, String attributes, LinkOption... options)
- Parameters:
path
- SeeFiles.readAttributes(Path, String, LinkOption...)
attributes
- SeeFiles.readAttributes(Path, String, LinkOption...)
options
- SeeFiles.readAttributes(Path, String, LinkOption...)
- Returns:
- See
Files.readAttributes(Path, String, LinkOption...)
-
getLastModifiedTime
public FileTime getLastModifiedTime(Path path, LinkOption... options)
- Parameters:
path
- SeeFiles.getLastModifiedTime(Path, LinkOption...)
options
- SeeFiles.getLastModifiedTime(Path, LinkOption...)
- Returns:
- See
Files.getLastModifiedTime(Path, LinkOption...)
-
-