答案:I/O
* Internally Java uses Unicode which are 16 bit characters.
For I/O Java uses UTF which may be more thatn 16 bits per character.
* Creating an instance of the File class does not create a file in the underlying operating system.
* Java uses two closely related encoding systems UTF and unicode.
* Most of the text data within a program uses standard ASCII,
most of which can easily be stored within one byte.
For reasons of compactness Java uses a system called UTF-8
for string literals, identifiers and other text within programs.
* FileInputStream and FileOutputStream
File I/O activities requires use of Exception handling.
The FileInputStream and FileOutputStream take some kind of File as a constructor.
This can be a String containing the file name, and instance of the File class or a FileDescriptor.
FileInputStream(File file)
FileInputStream(FileDescriptor fdObj)
FileInputStream(String name)
FileOutputStream(File file)
FileOutputStream(FileDescriptor fdObj)
FileOutputStream(String name)
FileOutputStream(String name, boolean append)
* BufferedInputStream and BufferedOutputStream
The Buffered streams are direct descendents of the Filter streams.
This increases efficiency as when a read occurs it is more likely to be from memory (fast)
than from disk (slow). This buffering means they are particularly useful if you are reading
in large amounts of data.
The BufferedInputStream and BufferedOutputStream take an instance of a stream class
as a constructor but may take a size parameter so you can tune the size of the buffer used.
BufferedInputStream(InputStream in)
BufferedInputStream(InputStream in, int size)
BufferedOutputStream(OutputStream out)
BufferedOutputStream(OutputStream out, int size)
* DataInputStream and DataOutputStream
The DataInputStream and OutputStream are used to read binary representations of Java primitives
in a portable way.It gives you access to a range of methods such as readDoble, readIn
that will work the same on different platforms.
These classes take an instance of a Stream as a constructor.
DataInputStream(InputStream in)
DataOutputStream(OutputStream out)
* The File class
The File class has three constructor versions. These are
File(String path)
File(String path, String name)
File(File dir, String name)
* RandomAccessFile
A random access file behaves like a large array of bytes stored in the file system.
The RandomAccessFile class is way out on it's own and doesn't fit neatly with the Stream I/O classes.
If you get answer possibilities that mix instances of RandomAccessFile with other streams,
then they are almost certainly the wrong answers.
RandomAccessFile is more like the File class than the Stream classes.
It is useful if you want to move backwards and forwards with in a file without re-opening it.
For its constructor RandomAccessFile takes either an instance of a File class or a string
and a read/write mode argument.
The mode argument can be either "r" for read only or "rw" can be read and written to.
If you attempt pass the name of a file as a constructor, RandomAccessFile will attempt to open
that file.
If you pass only the "r" parameter mode and the file does not exist an exception will be thrown.
If you pass the mode as "rw" RandomAccessFile will attempt to create the file
in the underlying operating system.
RandomAccessFile(File file, String mode)
RandomAccessFile(String name, String mode)
上一个:简述LayoutManager缺省值
下一个:简述modifier(public,protected,private我就不说了,大家都比较熟了)