View RSS Feed

Recent Blogs Posts

  1. Saving objects to file

    by , 11-10-2011 at 05:39 PM (My Java Tips)
    Sometimes it is useful to store objects in files which can be read later. Object is saved along with its state. Simply saying, an object with its data can be saved in a file. Objects are made persistent this way.

    The class whose object is to be saved should implements Serializable interface. We as a programmer are not supposed to add any method. The purpose of implementing interface is to tell the Java run time, which classes are to be serialized.

    Serializable interface ...
  2. File Operations In Java

    by , 11-08-2011 at 07: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 “” 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.

  3. Writing a file from JSP

    by , 05-24-2011 at 02:45 PM (My Java Tips)
    You may want to write a file from JSP page. For example, user fills a form and you want to persist the details on a text file on server. Now you need to know how to write text file from JSP.

    Remember, always give the path from root. In the given snippet, nameOfTextFile contains the file path. We will use FileOutputStream to write to the file.

    Java Code:
    <%@ page import="*"  %>
    String str = "form data goes here";