The text file can be written using the PrintWriter object.
Please refer to the following example:
<%@ page import= "java.io.*"%>
<%
String str = "Print Me";
Always give the path from root. This is way it almost always works.
String nameoftextfile = "/usr/anil/imp.txt";
try {
PrintWriter pw = new PrintWriter (new FileOutputStream (Nameoftextfile));
Pw.println (str);
Clean up
Pw.close ();
catch (IOException e) {
Out.println (E.getmessage ());
}
%>
Now, open imp.txt to see that the string "Print me" should already be written.
There is another way to use the IN16 tag Library's file tag to refer to http://sourceforge.net/project/?group_id=1282.
The syntax for the example is:
<ext:file action= "Write|append|create|copy|move|delete|rename|read" from= "<%= myfilename%>" >
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service