iT邦幫忙

DAY 20
1

Java重點學習筆記系列 第 20

Java重點筆記十八:InputStream 與 FileInputStream

  • 分享至 

  • xImage
  •  

InputStream是FileInputStream的上層(父層)。可用FileInputStream來建立一個InputStream的方法,然後用InputStream的方法(methods)進行操作。

InputStream f = new FileInputStream("C:/java/hello");

以下是InputStream的方法(methods):

1	public void close() throws IOException{}
This method closes the file output stream. Releases any system resources associated with the file. Throws an IOException.
2	protected void finalize()throws IOException {}
This method cleans up the connection to the file. Ensures that the close method of this file output stream is called when there are no more references to this stream. Throws an IOException.
3	public int read(int r)throws IOException{}
This method reads the specified byte of data from the InputStream. Returns an int. Returns the next byte of data and -1 will be returned if it's end of file.
4	public int read(byte[] r) throws IOException{}
This method reads r.length bytes from the input stream into an array. Returns the total number of bytes read. If end of file -1 will be returned.
5	public int available() throws IOException{}
Gives the number of bytes that can be read from this file input stream. Returns an int.

上一篇
Java重點筆記十七:Java的標準輸入輸出Standard I/O
下一篇
Java重點筆記 19:OutputStream 與 FileOutputStream
系列文
Java重點學習筆記30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言