Read file : File Save Load « JSP « Java Tutorial






<%@ page import="java.io.*" %>
<HTML>
    <HEAD>
        <TITLE>The file</TITLE>
    </HEAD>

    <BODY>
        <H1>The Guest Book</H1>
        Here are the current entries in the file: 
        <BR>
        <BR>
        <%
            String file = application.getRealPath("/") + "basic.jsp";
            File fileObject = new File(file);

            char data[] = new char[(int) fileObject.length()];
            FileReader filereader = new FileReader(file);

            int charsread = filereader.read(data);
            out.println(new String(data, 0 , charsread));

            filereader.close();
        %>
    </BODY>
</HTML>








23.51.File Save Load
23.51.1.Save Form Input to File using JSP
23.51.2.Index of Files
23.51.3.Read file
23.51.4.Writing Binary Data
23.51.5.Reading Binary Data