Java 流框架 学习笔记
2024-07-15 11:32:57 0 举报
AI智能生成
Java 流框架(InputStream,OutputStream,Reader,Writer)学习笔记
作者其他创作
大纲/内容
字节流
InputStream
方法
int read()
int read(byte[] b)
int read(byte[] b, int off, int len)
long skip(long n)
int available()
void close()
void mark(int readlimit)
boolean markSupported()
void reset()
子类
ByteArrayInputStream
FileInputStream
FilterInputStream
BufferedInputStream
DataInputStream
int readInt()
long readLong()
short readShort()
byte readByte()
char readChar()
boolean readBoolean()
double readDouble()
float readFloat()
void readFully(byte[] b)
void readFully(byte[] b, int off, int len)
String readUTF()
int skipBytes(int n)
GZIPInputStream
ZipInputStream
ZipEntry getNextEntry()
void closeEntry()
JarInputStream
StringBufferInputStream
ObjectInputStream
Object readObject()
OutputStream
方法
void write( int n)
void write(byte[] b)
void write(byte[] b, int off, int len)
void close()
void flush()
子类
ByteArrayOutputStream
FileOutputStream
FilterOutputStream
BufferedOutputStream
DataOutputStream
void writeInt(int i)
void writeLong(long l)
void writeShort(int s)
void writeByte(int b)
void writeChar(int c)
void writeChars(String s)
void writeBoolean(boolean b)
void writeDouble(double d)
void writeFloat(float f)
void writeUTF(String s)
GZIPOutputStream
ZipOutputStream
void putNextEntry(ZipEntry ze)
void closeEntry()
void setLevel(int level)
void setMethod(int method)
JarOutputStream
StringBufferOutputStream
ObjectOutputStream
void writeObject(Object o)
Zip文件相关类
ZipEntry:Zip压缩包中的项
long getCrc()
String getName()
long getSize()
boolean isDirectory()
void setMethod(int method)
void setSize(long size)
void setCrc(long crc)
ZipFile:Zip文件
Enumeration entries():可以枚举这个ZIP文件中各个项ZipEntry的Enumeration对象
ZipEntry getEntry(String name)
InputStream getInputStream(ZipEntry entry)
String getName():返回这个ZIP文件的路径
示例
读文件
写文件
示例
读文件
写文件
字符流
Reader
子类
BufferedReader
LineNumberReader
InputStreamReader
FileReader
StringReader
CharArrayReader
Writer
子类
BufferedWriter
OutputStreamWriter
FileWriter
StringWriter
CharArrayWriter
示例
读文件
写文件
文件类
File
static separator
String getName()
boolean exists()
boolean mkdir()
boolean mkdirs()
boolean delete()
boolean renameTo(File dest)
boolean isDirectory()
boolean isFile()
boolean createNewFile()
String getPath()
String getAbsolutePath()
File getAbsoluteFile()
String getParent()
File getParentFile()
String[] list()
String[] list(FilenameFilter filter)
File[] listFiles()
File[] listFiles(FilenameFilter filter)
Paths
Path get(String first, String...more):通过连接给定的字符串创建一个Path对象
Path
Path resolve(Path other)
Path resolve(String other)
Path resolveSibling(Path other)
Path resolveSibling(String other)
Path relatiivize(Path path)
Path normalize()
Path toAbsolutePath()
Path getParent()
Path getFileName()
Path getRoot()
File toFile()
Files
byte[] readAllBytes(Path path)
List readAllLines(Path path, Charset charset)
Path write(Path path, byte[] data)
Path write(Path path, byte[] data, OpenOption...options)
Path write(Path path, Iterable extends CharSequence> data, OpenOption...options)
InputStream newInputStream(Path path, OpenOption...options)
OutputStream newOutputStream(Path path, OpenOption...options)
BufferedReader newBufferedReader(Path path, Charset charset)
BufferedWriter newBufferedWriter(Path path, Charset charset, OpenOption...options)
Path copy(Path from, Path to, CopyOption...options)
Path move(Path from, Path to, CopyOption...options)
void delete(Path path)
void deleteIfExists(Path path)
Path createFile(Path path, FileAttribute>...attrs)
Path createDirectory(Path path, FileAttribute>...attrs)
Path createDirectories(Path path, FileAttribute>...attrs)
Path createTempFile(String prefix, String suffix, FileAttribute>... attrs)
Path createTempFile(Path parentDir, String prefix, String suffix, FileAttribute>... attrs)
Path createTempDirectory(String prefix, FileAttribute>... attrs)
Path createTempDirectory(Path parentDir, String prefix, FileAttribute>... attrs)
boolean exists(Path path)
boolean isHidden(Path path)
boolean isReadable(Path path)
boolean isWriter(Path path)
boolean isExecutable(Path path)
boolean isDirectory(Path path)
boolean isRegularFile(Path path)
boolean isSymbolicLink(Path path)
long size(Path path)
DirectoryStream newDirectoryStream(Path path):获取给定上当中可以遍历所有文件和目录的迭代器
DirectoryStream newDirectoryStream(Path path, String glob)
Path walkFileTree(Path start, FileVisitor super Path> visitor):遍历给定路径的所有子孙,并将访问器应用于这些子孙之上
0 条评论
下一页