public class IOHelper
extends java.lang.Object
路径帮助器
Path helper
Email: fishinlove@163.com
created by 2019/03/30 00:24:19
| 构造器和说明 |
|---|
IOHelper() |
| 限定符和类型 | 方法和说明 |
|---|---|
static java.nio.file.Path |
getResourceFromClasspath(java.lang.String resource)
从类路径中获得资源路径
Get path from classpath
|
static java.nio.file.Path |
getResourceFromFileSystem(java.lang.String resource)
从文件系统获得资源路径
Get path from file system
|
static java.lang.String |
linesOf(java.nio.file.Path resource,
java.nio.charset.Charset charset)
读取指定路径下的一个文件全部字符
当这个文件非常大的时候,有可能导致效率很低,耗费时间较多
Collect all lines of this file in path
If this file is huge enough, the speed will be slow enough
|
static java.io.InputStream |
newInputStream(java.nio.file.Path path)
根据指定路径获取一个资源输入流
Get a inputStream from given path
|
static java.io.InputStream |
newInputStreamToClasspath(java.lang.String path)
根据指定路径获取一个资源输入流
Get a inputStream from given path
|
static java.io.InputStream |
newInputStreamToFileSystem(java.lang.String path)
根据指定路径获取一个资源输入流
Get a inputStream from given path
|
static java.io.Reader |
newReader(java.nio.file.Path path,
java.nio.charset.Charset charset)
根据指定路径获取一个资源读取器
Get a reader from given path
|
static java.io.Reader |
newReaderToClasspath(java.lang.String path,
java.nio.charset.Charset charset)
根据类路径获取一个资源读取器
Get a reader from classpath
|
static java.io.Reader |
newReaderToFileSystem(java.lang.String path,
java.nio.charset.Charset charset)
根据文件系统获取一个资源读取器
Get a reader from file system
|
public static java.io.InputStream newInputStream(java.nio.file.Path path)
throws java.io.IOException
根据指定路径获取一个资源输入流
Get a inputStream from given path
path - 指定的路径
Given path
返回读取器
Return inputStream
java.io.IOException - 获取资源输入流异常
Get inputStream failed
public static java.io.InputStream newInputStreamToFileSystem(java.lang.String path)
throws java.io.IOException
根据指定路径获取一个资源输入流
Get a inputStream from given path
path - 指定的路径
Given path
返回读取器
Return inputStream
java.io.IOException - 获取资源输入流异常
Get inputStream failed
public static java.io.InputStream newInputStreamToClasspath(java.lang.String path)
throws java.io.IOException
根据指定路径获取一个资源输入流
Get a inputStream from given path
path - 指定的路径
Given path
返回读取器
Return inputStream
java.io.IOException - 获取资源输入流异常
Get inputStream failed
public static java.io.Reader newReader(java.nio.file.Path path,
java.nio.charset.Charset charset)
throws java.io.IOException
根据指定路径获取一个资源读取器
Get a reader from given path
path - 指定的路径
Given path
charset - 字符集
Charset
返回读取器
Return reader
java.io.IOException - 获取读取器异常
Get reader failed
public static java.io.Reader newReaderToFileSystem(java.lang.String path,
java.nio.charset.Charset charset)
throws java.io.IOException
根据文件系统获取一个资源读取器
Get a reader from file system
path - 文件系统路径
Given path
charset - 字符集
Charset
返回读取器
Return reader
java.io.IOException - 获取读取器异常
Get reader failed
public static java.io.Reader newReaderToClasspath(java.lang.String path,
java.nio.charset.Charset charset)
throws java.io.IOException
根据类路径获取一个资源读取器
Get a reader from classpath
path - 类路径资源
Given path in classpath
charset - 字符集
Charset
返回读取器
Return reader
java.io.IOException - 获取读取器异常
Get reader failed
public static java.nio.file.Path getResourceFromClasspath(java.lang.String resource)
从类路径中获得资源路径
Get path from classpath
resource - 类路径中的资源
The resource of classpath
返回指向类路径中这个资源的路径对象
Return a path to this resource in classpath
public static java.nio.file.Path getResourceFromFileSystem(java.lang.String resource)
从文件系统获得资源路径
Get path from file system
resource - 文件系统中的资源
The resource of file system
返回指向文件系统中这个资源的路径对象
Return a path to this resource in file system
public static java.lang.String linesOf(java.nio.file.Path resource,
java.nio.charset.Charset charset)
读取指定路径下的一个文件全部字符
当这个文件非常大的时候,有可能导致效率很低,耗费时间较多
Collect all lines of this file in path
If this file is huge enough, the speed will be slow enough
resource - 要被读取的文件路径
The path of this file
charset - 读取使用的字符集
The charset of this file
返回这个文件的全部字符
Return all chars in this file
Copyright © 2019. All Rights Reserved.