Package com.landawn.abacus.guava
Class Files
java.lang.Object
com.landawn.abacus.guava.Files
- Direct Known Subclasses:
Files.MoreFiles
Copied from Google Guava under Apache License v2.
The purpose is to provide unified API.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.common.io.ByteSink
asByteSink
(File file, com.google.common.io.FileWriteMode... modes) As byte sink.static com.google.common.io.ByteSink
asByteSink
(Path path, OpenOption... options) As byte sink.static com.google.common.io.ByteSource
asByteSource
(File file) As byte source.static com.google.common.io.ByteSource
asByteSource
(Path path, OpenOption... options) As byte source.static com.google.common.io.CharSink
asCharSink
(File file, Charset charset, com.google.common.io.FileWriteMode... modes) As char sink.static com.google.common.io.CharSink
asCharSink
(Path path, Charset charset, OpenOption... options) As char sink.static com.google.common.io.CharSource
asCharSource
(File file, Charset charset) As char source.static com.google.common.io.CharSource
asCharSource
(Path path, Charset charset, OpenOption... options) As char source.static void
static void
copy
(File from, OutputStream to) static void
createParentDirectories
(Path path, FileAttribute<?>... attrs) Creates the parent directories.static void
createParentDirs
(File file) Creates the parent dirs.static File
Deprecated.static void
deleteDirectoryContents
(Path path, com.google.common.io.RecursiveDeleteOption... options) Delete directory contents.static void
deleteRecursively
(Path path, com.google.common.io.RecursiveDeleteOption... options) static boolean
static boolean
static com.google.common.graph.Traverser<File>
static String
getFileExtension
(String fullName) Gets the file extension.static String
getFileExtension
(Path path) Gets the file extension.static String
Gets the name without extension.static String
getNameWithoutExtension
(Path path) Gets the name without extension.static ImmutableList<Path>
static MappedByteBuffer
static MappedByteBuffer
map
(File file, FileChannel.MapMode mode) static MappedByteBuffer
map
(File file, FileChannel.MapMode mode, long size) static void
static BufferedReader
static BufferedWriter
static com.google.common.graph.Traverser<Path>
static String
simplifyPath
(String pathname) static byte[]
toByteArray
(File file) To byte array.static void
static void
static void
-
Method Details
-
newReader
- Parameters:
file
-charset
-- Returns:
- Throws:
FileNotFoundException
- the file not found exception
-
newWriter
- Parameters:
file
-charset
-- Returns:
- Throws:
FileNotFoundException
- the file not found exception
-
asByteSource
As byte source.- Parameters:
file
-- Returns:
-
asByteSource
@SafeVarargs public static com.google.common.io.ByteSource asByteSource(Path path, OpenOption... options) As byte source.- Parameters:
path
-options
-- Returns:
-
asByteSink
@SafeVarargs public static com.google.common.io.ByteSink asByteSink(File file, com.google.common.io.FileWriteMode... modes) As byte sink.- Parameters:
file
-modes
-- Returns:
-
asByteSink
@SafeVarargs public static com.google.common.io.ByteSink asByteSink(Path path, OpenOption... options) As byte sink.- Parameters:
path
-options
-- Returns:
-
asCharSource
As char source.- Parameters:
file
-charset
-- Returns:
-
asCharSource
@SafeVarargs public static com.google.common.io.CharSource asCharSource(Path path, Charset charset, OpenOption... options) As char source.- Parameters:
path
-charset
-options
-- Returns:
-
asCharSink
@SafeVarargs public static com.google.common.io.CharSink asCharSink(File file, Charset charset, com.google.common.io.FileWriteMode... modes) As char sink.- Parameters:
file
-charset
-modes
-- Returns:
-
asCharSink
@SafeVarargs public static com.google.common.io.CharSink asCharSink(Path path, Charset charset, OpenOption... options) As char sink.- Parameters:
path
-charset
-options
-- Returns:
-
toByteArray
To byte array.- Parameters:
file
-- Returns:
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
- Parameters:
from
-to
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
equal
- Parameters:
file1
-file2
-- Returns:
- true, if successful
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
equal
- Parameters:
path1
-path2
-- Returns:
- true, if successful
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
touch
- Parameters:
file
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
touch
- Parameters:
path
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
createTempDir
Deprecated.For Android users, see the Data and File Storage overview to select an appropriate temporary directory (perhapscontext.getCacheDir()
). For developers on Java 7 or later, useFiles.createTempDirectory(java.nio.file.Path, java.lang.String, java.nio.file.attribute.FileAttribute<?>...)
, transforming it to aFile
usingtoFile()
if needed.- Returns:
-
createParentDirs
Creates the parent dirs.- Parameters:
file
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
createParentDirectories
@SafeVarargs public static void createParentDirectories(Path path, FileAttribute<?>... attrs) throws IOException Creates the parent directories.- Parameters:
path
-attrs
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
copy
- Parameters:
from
-to
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
copy
- Parameters:
from
-to
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
move
- Parameters:
from
-to
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
readLines
- Parameters:
file
-charset
-- Returns:
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
map
- Parameters:
file
-- Returns:
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
map
- Parameters:
file
-mode
-- Returns:
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
map
public static MappedByteBuffer map(File file, FileChannel.MapMode mode, long size) throws IOException - Parameters:
file
-mode
-size
-- Returns:
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
simplifyPath
- Parameters:
pathname
-- Returns:
-
getNameWithoutExtension
Gets the name without extension.- Parameters:
file
-- Returns:
-
getNameWithoutExtension
Gets the name without extension.- Parameters:
path
-- Returns:
-
getFileExtension
Gets the file extension.- Parameters:
fullName
-- Returns:
-
getFileExtension
Gets the file extension.- Parameters:
path
-- Returns:
-
fileTraverser
- Returns:
-
pathTraverser
- Returns:
-
listFiles
- Parameters:
dir
-- Returns:
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
deleteRecursively
@SafeVarargs public static void deleteRecursively(Path path, com.google.common.io.RecursiveDeleteOption... options) throws IOException - Parameters:
path
-options
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
deleteDirectoryContents
@SafeVarargs public static void deleteDirectoryContents(Path path, com.google.common.io.RecursiveDeleteOption... options) throws IOException Delete directory contents.- Parameters:
path
-options
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
context.getCacheDir()
).