Couple of Days back i started reading Beginning Java 2, JDK 5 Edition By Ivor Horton.
Nice book written by Ivor Horton.
Below are few quotations i found from this book from the next 3 chapters ( 10-11-12).
1) A FileChannel object for a file is returned by the getChannel() method for a file stream object.
2) A buffer contains data to be written to a file or data that has been read from a file. Only ByteBuffer objects can be used directly in file I/O operations.
3) A buffer’s position is the index position of the first element in the buffer to be written or read. A buffer’s limit specifies the index position of the first element that is not to be written or read.
4) A view buffer is a buffer that allows the data in a backing byte buffer to be viewed as being of a particular basic type.
5) You insert data into a buffer using its put() methods and retrieve data from it using its get() methods. Relative get() and put() methods increment the buffer’s position, whereas absolute get() and put() methods do not.
6) You write the contents of a ByteBuffer object to a file using a write() method belonging to the FileChannel object for the file.
7) The amount of data transferred between a buffer and a file in an I/O operation is determined by the buffer’s position and limit. Data is read or written starting at the file’s current position.
8) You can read a file using a FileChannel object obtained from a FileInputStream object or from a RandomAccessFile object.
9) You can use a channel obtained from a RandomAccessFile object that was created with mode "rw", "rwd", or "rws" to both read and write the file.
10) Data that is read from a file using a channel is stored in one or more buffers of type ByteBuffer.
11) You can use view buffers to interpret the data read from a file as any basic type other than boolean.
12) A memory-mapped file enables you to access data in the file as though it were resident in memory.You access a memory-mapped file through a MappedByteBuffer object.
13) Acquiring an exclusive lock on a file ensures that no other program can access the file while you hold the lock. You can obtain an exclusive lock only on a file you have opened for both reading and writing.
14) Acquiring a shared lock on a file ensures that your program has access to the file in circumstances where other programs may be accessing the same file, and protects the region of the file you have locked from being altered.
15) The process of storing and retrieving objects in an external file is called serialization. Writing an object to a file is referred to as serializing the object, and reading an object from a file is called deserializing an object.
16) To make objects of a class serializable the class must implement the Serializable interface.
17) If a class has a superclass that does not implement the Serializable interface, then the superclass must have a public default constructor if it is to be possible to serialize the class.
18) Objects are written to a file using an ObjectOutputStream object and read from a file using and ObjectInputStream object.
19) Objects are written to a file by calling the writeObject() method for the ObjectOutputStream object corresponding to the file.
20) Objects are read from a file by calling the readObject() method for the ObjectInputStream object corresponding to the file.
21) When necessary—for example, if a superclass is not serializable—you can implement the readObject() and writeObject() methods for your classes.
About the Author
Ivor Horton started out as a mathematician, but shortly after graduating, he was lured into messing about with computers by a well-known manufacturer. He has spent many happy years programming occasionally useful applications in a variety of languages as well as teaching mainly scientists and engineers to do likewise. He has extensive experience in applying computers to problems in engineering design and to manufacturing operations in a wide range of industries. He is the author of a number of tutorial books on programming in C, C++, and Java. When not writing programming books or providing advice to others, he leads a life of leisure.
Friday, 3 October 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment