View RSS Feed

My Java Tips

  1. Retrieving serialized objects from file

    by , 11-10-2011 at 04:35 PM (My Java Tips)
    I assume that you are aware of how to serialize objects and save them into files on the disk. Now I will talk about how to retrieve serialized objects.


    You have to use FileInputStream and ObjectInputStream to fetch the object. Specify the file which contains the object in FileInputStream. Once ObjectInputStrem is initialized, just use in.readObject method of ObjectInputStream to fetch the object.

    In the following example, I am fetching a Vector from a file on disk. ...
  2. File Operations In Java

    by , 11-08-2011 at 06:48 PM (My Java Tips)
    Through file handling, we can read data from and write data to files besides doing all sorts of other operations. Java provides a number of methods for file handling through different classes which are a part of the “java.io” package.

    The question can arise in the mind of a new programmer as to why file-handling is required. The answer of this question would be in two parts, why do we need to read data from the files and why do we need to save it (write it) to a file.

    ...