Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
JSP Open File 
 

JSP Open File is used to create a file and write a text into the file.

 

JSP Open File

                          

JSP Open File is used to create a file and write a text into the file.

Understand with Example

 The Tutorial illustrate an example from JSP Open File. To understand the example we create openFile.jsp that include a page import directive "java.io" package. The java.io package  provides for system input and output through data streams, serialization and the file system. For this, we have create a file 'Hello.txt' in the C:drive. The  class FileOutputStream opens an output stream in order to write the specified text of line using the class PrintStream. In case the exception occurred , the catch block handle the exception and print the 'Unable to write to file'.

Here is the code of openFile.jsp

<%@ page import="java.io.*"%>
<%
FileOutputStream out; 
try{
out = new FileOutputStream("C://Hello.txt");
new PrintStream(out).println ("All glitters are not gold");
out.close(); 
}
catch (IOException e){
out.println ("Unable to write to file");
}
%>

When you run the above jsp code, the line of text, you have specified, will be written into the file Hello.txt.

Download Source Code:

                          

» View all related tutorials
Related Tags: java html c web jsp dynamic static script servlet sed ip page tag this log tar close js start technology

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

Read and write Large file size of the video file using jsp, when i am access the large file size i am getting outofmemoryerror

Posted by rams on Monday, 04.6.09 @ 15:20pm | #86547

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.