public class File extends File
pathSeparator, pathSeparatorChar, separator, separatorChar| 构造器和说明 |
|---|
File(File file) |
File(File parent,
String child) |
File(String path) |
File(String parent,
String child) |
File(URI uri) |
| 限定符和类型 | 方法和说明 |
|---|---|
String |
getExtension()
获取文件扩展名
|
String |
getMd5()
获取文件 MD5 值
|
MimeType |
getMimeType()
获取文件 MimeType
|
String |
getSha1()
获取文件 SHA1 值
|
byte[] |
read()
读取文件内容
|
boolean |
rename(String newName)
重命名文件
|
void |
write(byte[] bytes)
向文件写内容
|
void |
write(byte[] bytes,
boolean append)
向文件写内容
|
void |
write(char[] chars)
向文件写内容
|
void |
write(char[] chars,
boolean append)
向文件写内容
|
void |
write(String str)
向文件写内容
|
void |
write(String str,
boolean append)
向文件写内容
|
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toPath, toString, toURI, toURLpublic File(String path)
path - 文件路径public File(File file)
file - java.io.Filepublic File(URI uri)
uri - URIpublic MimeType getMimeType()
public byte[] read()
throws IOException
IOException - IO 异常public void write(String str) throws IOException
str - 待写入内容IOException - IO 异常public void write(char[] chars)
throws IOException
chars - 待写入内容IOException - IO 异常public void write(byte[] bytes)
throws IOException
bytes - 待写入内容IOException - IO 异常public void write(String str, boolean append) throws IOException
str - 待写入内容append - 是否追加写入IOException - IO 异常public void write(char[] chars,
boolean append)
throws IOException
chars - 待写入内容append - 是否追加写入IOException - IO 异常public void write(byte[] bytes,
boolean append)
throws IOException
bytes - 待写入内容append - 是否追加写入IOException - IO 异常public String getMd5() throws IOException
FileNotFoundException - 当文件不存在IOException - IO 异常public String getSha1() throws IOException
FileNotFoundException - 当文件不存在IOException - IO 异常public String getExtension() throws IOException
IOException - IO 异常public boolean rename(String newName)
newName - 新文件名Copyright © 2023 buession.com Inc.. All rights reserved.