Java file operations Daquan 1: the establishment of documents, checks and delete
Abstract: Java file operations Daquan 1: the establishment of documents, checks and delete
</ Td> </ tr> <tr> <td width="443" height="35" valign="top" class="ArticleTeitle"> <% @ page contentType = "text / html; gb2312 charset ="% >
<% @ Page import = "java.io. *"%>
<head>
</ Head>
<body>
<%
String path = request.getRealPath ( "/ article/article5a/example/filetest");
Out.println (path + "
");
File f = new File (path, "File.txt");
Out.println (f + "
");
/ / Out.println (f.exists ());
If (f.exists ()){// check whether there File.txt
F.delete ();// delete documents File.txt
Out.println (path + "\ \ File.txt exist, has been deleted.");
Else ()
F.createNewFile ();// under the current directory creation of a document entitled File.txt
Out.println (path + "\ \ File.txt did not exist, the current output has been established 。");// the directory path
)
%>
</ Td> <td width="264" valign="top" class="ArticleTeitle">
</ Td> </ tr> <tr> <td height="25" colspan="2" valign="top" class="ArticleTeitle">
↑ Back
Java file operations Daquan 4: read the paper
Abstract: Java file operations Daquan 4: read the paper
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <% @ page contentType = "text / html; gb2312 charset ="%>
<% @ Page import = "java.io. *"%>
<head>
</ Head>
<body>
<%
String path = request.getRealPath ( "/ article/article5a/example/filetest"); / / Get the current directory path
FileReader fr = new FileReader (path + "ReadData.txt ");// establish FileReader object, and examples into fr
BufferedReader br = new BufferedReader (fr); / / build BufferedReader object, and examples into br
String Line = br.readLine ();// his string read from the document
/ / Reader to judge whether the string is empty
While (Line! = Null) (
Out.println (Line + "
");// Read from the paper output data
Line = br.readLine ();// continue to read from the document in his data
)
Br.close ();// closed BufferedReader target
Fr.close ();// closing documents
%>
</ Body>
<table Width="730" border="0"> <tr> <td width="724"> </ td> </ tr> </ table> </ td> </ tr> <tr>
↑ Back
Java file operations Daquan 2: directory establishment of checks and delete
Abstract: Java file operations Daquan 2: Contents of the establishment of checks and delete
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width="729" border="0"> <tr> <td width = " 723 "> </ td> </ tr> </ table>
<% @ Page contentType = "text / html; gb2312 charset ="%>
<% @ Page import = "java.io. *"%>
<head>
</ Head>
<body>
<%
String path = request.getRealPath ( "/ article/article5a/example/filetest");
Path = path + "\ \ Sub" / / will be established by the directory path
File d = new File (path); / / Sub directory that represents the File object, and a quote to get it
If (Sub d.exists ()){// check whether there directory
D.delete ();
Out.println ( "Sub directory exists, has been deleted");
Else ()
D.mkdir ();// establish Sub directory
Out.println ( "Sub directory does not exist, has been established");
)
%>
</ Body>
</ Td> </ tr> <tr>
↑ Back
Using JSP branch of the write-read paper
Abstract: JSP branch of the write-read paper
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle">
<table Width="705" border="0"> <tr> <td width="421"> <% @ page contentType = "text / html; charset = GB2312"%>
<% @ Page language = "java"%>
<% @ Page import = "java.io. *"%>
<head>
</ Head>
<body>
Branch writes data
</ Td> <td width="274"> </ td> </ tr> </ table>
<%
Request.getRealPath ("/"); String path = / / actual location of the root
FileWriter fw = new FileWriter (path + "\ \ WriteFile.txt"); / / build FileWrite variables, and set the variables used by fw
BufferedWriter bw = new BufferedWriter (fw); / / build BufferedWriter variables, and set the variables used by bw
/ / String into the file
Bw.write ( "Good morning!");
Bw.newLine (); / / branch
Bw.write ( "You are welcome to study jsp!");
Bw.newLine (); / / branch
Bw.write ( "I wish you all a happy learning jsp!");
Bw.newLine (); / / branch
Bw.write ( "Byebye!");
Bw.flush () / / will be updated to file information
Fw.close () / / close file
%>
To write the contents of the documents
<%
FileReader fr = new FileReader (path + "\ \ WriteFile.txt"); / / build FileReader variables, variables and set variables used by the fr
BufferedReader br = new BufferedReader (fr); / / read the variable BufferedRead
String Line = br.readLine (); / / read his information
While (Line! = Null) / / read the information obtained by the judge whether null
(
Out.println (Line + "
"); / / Output read the information obtained
Line = br.readLine (); / / read his information
)
Fr.close () / / close file
%>
</ Body>
</ Td> </ tr> <tr>
↑ Back
Xml document for use with mysql database connection pool proxool
Abstract: xml document with mysql database connection pool proxool
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> 1, to write xml documents: WEB Proxool.xml Add to your application's WEB-INF \ classes below, as follows: XmlFile WEB-INF/classes/Proxool.xml
<? Xml version = "1.0" encoding = "ISO-8859-1">
Anything outside the "proxool" tag is ignored.
<table Width="681" border="0"> <tr> <td width="399">
</ Td> <td width="272"> </ td> </ tr> </ table>
2, so write web.xml:
<? Xml version = "1.0" encoding = "ISO-8859-1">
Web-app
PUBLIC "- / / Sun Microsystems, Inc / / DTD Web Application 2.3 / / EN"
"Http://java.sun.com/dtd/web-app_2_3.dtd">
3, will be the driving procedures mm.mysql-2.0.14-bin.jar and proxool-0.8.3.jar and crimson.jar Add WEB-INF \ lib directory.
4, test jsp documents:
<% @ Page import = "java.sql .*"%>
<% @ Page contentType = "text / html; charset = GB2312"%>
<head>
</ Head>
<body>
Use Proxool Connection Pool with the xml file allocation
<%
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
Try (
Con = DriverManager.getConnection ( "proxool.xml-test");
Stmt = con.createStatement ();
String query = "select * from count_num";
Rs = stmt.executeQuery (query);
While (rs.next ()) (
Out.print (rs.getLong (1 )+"– OK ");
)
Stmt.close ();
Con.close ();
) Catch (SQLException sqle) (
Out.println ( "sqle =" + sqle);
)
Finally (
Try (
If (con! = Null) (
Con.close ();
)
) Catch (SQLException sqle) (
Out.println ( "sqle =" + sqle);
)
)
%>
</ Body>
5, statistics and background information
Please go to: http://127.0.0.1:8080/testpxool1/Admin
(Testpxool1 should read your application WEB) </ td> </ tr> <tr>
↑ Back
Jboss4 installation testing
Abstract: jboss4 installation testing
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> 1, download and install
<1> to download http://www.jboss.org/ can download, I was under the jboss-4.0.0DR4.
<2> installation method is to extract the files to a hard drive directory (for example: My solution to the c: \ jboss4).
2, installed j2sdk1.4.
Jboss without java standards development kits. I installed the 1.4 install directory is C: \ j2sdk1.4
3, run
Jboss4 entered the bin directory, we can implement run.bat. See the emergence of
INFO [Server] JBoss (MX MicroKernel) [4.0.0DR4 (build: CVSTag = HEAD
Date = 200405190212)] Started in 55s: 851ms
Such messages on the success of the launch, the following test methods
Http://localhost:8080/jmx-console you will see jmx agent view zz2zcwb
4, the use of
<1> html, jsp test
Jboss web directory is the default in jboss4 \ server \ default \ deploy below. Below introduced on the test jsp, servlet approach:
The first test in the establishment of a test.war deploy folder, and then html, jsp files can be put to test here
Such as the establishment of a test.jsp as follows:
<% @ Page language = "java"%>
<% @ Page contentType = "text / html; gb2312 charset ="%>
<% @ Page import = "java.util .*"%>
<% = New Date (). ToString ()%>
Http://localhost:8080/test/test.jsp can be called by the current date and time.
<2> set sql server2000 data sources in the parade and then call jsp Database
<<1>> to download and install sql server2000 the jdbc drive (Microsoft)
<<2>> will mssqlserver, msbase, msutil three jar files copied to jboss4 \ server \ default \ lib directory
<<3>> will jboss4 \ docs \ examples \ jca \ mssql-ds.xml a copy to jboss4 \ server \ default \ deploy Below
Part amended to read as follows:
The above configuration is used as a data source ds name with a non-password users connect sa sql server database model northwind. You can make the appropriate changes.
<<4>> configuration completed, the document by the following test database operations testSql.jsp
<table Width="670" height="27" border="0"> <tr> <td width="383"> <% @ page language = "java"%>
<% @ Page import = "javax.naming .*"%>
<% @ Page import = "javax.sql .*"%>
<% @ Page import = "java.sql .*"%>
<%!
Javax.sql.DataSource ds;
%>
<%
Try (
Context ctx = new InitialContext ();
Ds = (javax.sql.DataSource) ctx.lookup ( "java: / ds");
) Catch (Exception e) (
Out.println ( "erro when connect to java naming api");
) </ Td> <td width="277"> </ td> </ tr> </ table>
Connection conn = ds.getConnection ();
Statement st = conn.createStatement ();
String sqlStr = "select * from categories";
ResultSet rs = st.executeQuery (sqlStr);
While (rs.next ()) (
Out.println (rs.getString ( "categoryName") + "
");
)
Rs.close ();
St.close ();
Conn.close ();
%>
Table output categories for each record categoryName, it is noteworthy that in the mssql-ds.xml set jndi-name is ds, and the bonding is real
Java: / ds.
<3> servlet test configuration
<<1>> prepared and compiled the following simple servlet
Import java.io. *;
Import javax.servlet .*;
Import javax.servlet.http .*;
Public class HelloWorld extends HttpServlet (
Public void doGet (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException (
Response.setContentType ( "text / html");
PrintWriter out = response.getWriter ();
Out.println ("");
Out.println ( "Hello World");
)
)
<<2>> test.war folder in the establishment of a WEB-INF directory, again inside the establishment of a directory of classes and web.xml file directory structure is as follows:
[Test.war]
[WEB-INF]
[Classes]
Web.xml
Compiler will be available to the success of HelloWorld.class classes directory, web.xml as follows:
<? Xml version = "1.0">
Web-app PUBLIC
"- / / Sun Microsystems, Inc / / DTD Web Application 2.3 / / EN"
"Http://java.sun.com/dtd/web-app_2_3.dtd">
By calling http://localhost:8080/test/HelloWorld hello world can see the output
</ Td> </ tr> <tr>
↑ Back
Java file operations Daquan 6: Skip bytes do not read
Abstract: Java file operations Daquan 6: Skip bytes do not read
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width="730" border="0"> <tr> <td width = " 724 "> </ td> </ tr> </ table>
<% @ Page contentType = "text / html; gb2312 charset ="%>
<% @ Page import = "java.io. *"%>
<head>
</ Head>
<body>
<%
String path = request.getRealPath ( "/ article/article5a/example/filetest");
FileReader fr = new FileReader (new File (path, "ReadData.txt "));// establish FileReader object, and examples into fr
Out.println ( "the current directory:" + path + "
");
Fr.skip (2); / / Skip two bytes
Out.println ( "read out the contents of the documents:" + "
");
Int c = 1 byte read fr.read ();//
While (c! =- 1) (
Out.print ((char) c);
C = fr.read ();
)
Fr.close ();
%>
</ Body>
Attachment: ReadData.txt:
ASFFFAF
3234242 </ td> </ tr> <tr>
↑ Back
JFreeChart map generated popular among hungry students
Abstract: JFreeChart map generated popular among hungry students
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> decompress documents jfreechart-0.9.11 directory and the jfreechart-lib 0.9.11.jar / jcommon-0.8.6.jar, lib / gnujaxp.jar are required for the operation of the development of the document, these three documents available to the application lib directory.
<table Width="676" border="0"> <tr> <td width="399"> web.xml file and then add the following:
Test code:
<% @ Page contentType = "text / html; GBK charset ="%>
<% @ Page import = "org.jfree.data.DefaultPieDataset"%>
<% @ Page import = "org.jfree.chart.JFreeChart"%>
<% @ Page import = "org.jfree.chart.plot.PiePlot"%>
<% @ Page import = "org.jfree.chart.ChartRenderingInfo"%>
<% @ Page import = "org.jfree.chart.servlet.ServletUtilities"%>
<% @ Page import = "org.jfree.chart.urls.StandardPieURLGenerator"%>
<% @ Page import = "org.jfree.chart.entity.StandardEntityCollection"%>
<%
DefaultPieDataset data = new DefaultPieDataset ();
Data.setValue ( "June", 500);
Data.setValue ( "July", 580);
Data.setValue ( "August", 828);
PiePlot plot = new PiePlot (data);
JFreeChart chart = new JFreeChart ( "", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
Chart.setBackgroundPaint (java.awt.Color.white); / / optional, and set the background color picture
Chart.setTitle ( "TAB ");// www.SenTom.net optional site visits, set up title picture
ChartRenderingInfo info = new ChartRenderingInfo (new StandardEntityCollection ());
/ / Length of 500 pictures, 300 is a high degree of picture
String filename = ServletUtilities.saveChartAsPNG (chart, 500, 300, info, session);
String graphURL = request.getContextPath () + "/ servlet / DisplayChart? Filename =" + filename;
Out.println (filename + "
");
Out.println (graphURL);
%>
<head>
</ Head>
<body>
"Width = 500 height = 300 border = 0 usemap ="#<%= filename%>">
</ Body>
</ Td> </ tr> <tr>
↑ Back
Java file operations Daquan 5: directory listed in the document
Abstract: Java file operations Daquan 5: directory listed in the document
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width="734" border="0"> <tr> <td width = " 728 "> </ td> </ tr> </ table> ↑ Back Abstract: Carp Forum </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width = "100%" border = "0" cellspacing = "0" cellpadding = " 0 "> <tr> <td width="286" height="86" align="center" valign="top"> </ td> <td width="398" valign="top">
"Lei Yue Forum Version 2.0" to explain [Statement] Since the issue of domain name service providers, "Carp Forum" will be used to the new names visit: http://www.liyunet.com/bbs/. (New) Contact QQ: 39666 7718 MSN: liyunet@hotmail.com EMAIL: liyunet@yeah.net (New) demonstration Address: http://www.liyunet.com/bbs/ Version 2.0 updates: </ Td> </ tr> </ table>
This version is a basic function of the Forum added, and add some new features, the restoration of the original internal interface and display a number of problems. Add "forum for generating static HTML pages" function (carp forum text version) and the contents removed and the posting of information unrelated things, the Forum makes browsing faster, more targeted content. [Note] 1, the use of "Generation Text version Carp Forum" before in the configuration file into the application's physical path, the system will default to the application directory generation / bbs / html /. 2, if you use email function, first in the configuration file configuration own e-mail information. 3, in order to avoid Chinese gibberish, we strongly recommend the use of Resin2.1.14 for testing servers, such as avoiding the use Tomcat. Resin Application attention in the allocation of the time in the configuration file (the default for resin.conf) in the web-app-label attribute character encoding = 'GBK' guarantee with Chinese GBK transmission parameters. Carp Forum - E-commerce technology view: http://www.liyunet.com/bbs/list.jsp?forumID=2 Liyunet.com "carp fishing nets," thank you for your support! Version 1.0 updates: This version is updated version of small, the main changes in the course of the operation of the BUG, organize forums source files, modify or rewrite parts of modules designed to improve the operating efficiency and stability. Configuration files originally wanted to write XML documents, but readers feel efficiency is not very high, and now it is not necessary. Major revisions are as follows: Forum Posts repaired back, in the list can not be real-time display page error [Note] hash problem RESIN2.1.4, MYSQL4.1 and JDBC code and database connectivity through GBK circumstances will not arise. Download Address: Http://bbs.on-ly.com/ Platform: In RESIN2.1.4, MYSQL4.1 under test pass. RESIN recommended as a server. If you use TOMCAT, as it defaults to ISO-8859-1 encoding transmission parameters, so-Chinese parameters need to be encoded into GBK that will be normal. If you use other servers were garbled, check first whether the hash in the database, if it is requested to modify / WEB-INF/systemconfig.properties documents It will be inserted into the data encoded into the database before. If the database normal page for the hash, then modify / WEB-INF/systemconfig.properties documents I think in the following versions of all configurations to a centralized function module, more convenient to use! Traditional need to support the import, or write to the Douchushuju before coding conversion, JDBC and databases using ISO-8859-1 format communications. Installation Method: Decompression RESIN2.1.4, installed MYSQL4.1, mysql.txt SQL statement in the introduction to the database, the default name for the database: forum. Background note: August of this year, accidentally e-commerce is a result of the advent of all the major websites to launch in the corresponding e-commerce platform, younger brother also like to own a small space, we will proceed to do his own "Lei Yue mall." use of spare time, and finally after three months, like a small point, the international domain name applications: on-ly.com on-ly.cn, and the online operation of the relatively normal and happy while feeling Shaoledian what … …, that is, its own small forum, said Zuojiuzuo, so I analyzed what they do a new, time and energy, are not feasible, such as the Internet DOWN that I find some of the more well-known Community forums, such as the JIVE, Tianyi community, Azerbaijan vegetables Forum, JIVE course did not have to say that, all doing very well, but now is a commercial version, and the program structure of the younger brother of the case more complicated, I just want to to a simple and practical small Dongdong, so no need to slaughter this line, took that to Tianyi community, it is indeed a rare good thing, whether practical, and its technology, did not have to say that, Even the structure of procedures are清淅level, the younger brother this level can understand the (great achievement), but one thing is not in line with my request, it is the allocation of more, I just want it is a "supporter "A dish forum to repeat it, simplicity, function well, with easy configuration, and I am really in need of almost, but (Why always But) I find the new online version of the official website will no longer seemed to provide support download from procedural mistakes and not place more, from that time, technology has advanced, but is now somewhat backward, operating efficiency to be improved. With the above analysis, I decided that "A dish Forum" on the basis of the current use of new technologies, makes its operational efficiency and stability has been further improved, so I limited in the time and effort, add the following things: Technology Forum set: 1, built-C3P0, proxool, dbcp database connection pool! In short, personal feeling efficiency is raised. Of course, but also the common people to improve its quality. [Note] Since everyone time and energy is limited, there now exists the wrong forum inevitable, so please everyone together perfect. If there is any construction or good ideas, please contact me or visit online at the "Lei Yue Mun Forum" http://bbs.on-ly.com My E-mail: on-ly@yeah.net, MSN: on-ly.com @ hotmail.com, QQ: 39666 7718 Main features: (1). Prospects function 1. User registration: Only in terms of the Forum and fill out the registration information to users in a posting at the forum, the new user registration system will automatically prompts users to information, users are free to customize their head of information and signatures (support ubb label). 2. Landing users: may choose landing pages or landing directly in the postings on the landing, the system automatically record user login information, users can be released only landing postings. 3. Modifications: users can be their own landing of the original registration information changes. 4. Short message: landing users in the forums of any registered users to send short message, users can read the information and delete operations, upon receipt of text messages when the system will automatically remind. 5. Ranked Forum: Forum on the current support of the post in accordance with the number of registered users and registration time for Canada 6. Search Forum: Forum support for the title, content, the spokesman, id postings, the latest postings, the most popular postings, and other enquiries. 7. Released postings: landing (registered) users can lock in the absence of freedom within the forum postings, the Forum currently supports a variety of UBB grammar, textures, connectivity, insert Flash, html and debugging can be carried out the operation, you can choose quote responses and direct response, please see the use of specific uub help ubb related forums. 8. Resume postings: landing (registered) users can not lock on the theme of return, the speaker format Ibid. 9. Editor Notes: users can post their own published articles on the revision of moderators and administrators have the authority to edit all postings, the same class users can edit each other. 10. Online: detailed statistics users online accurate information, users can list browser, the system,
<% @ Page contentType = "text / html; gb2312 charset ="%>
<% @ Page import = "java.io. *"%>
<head>
</ Head>
<body>
<%
String path = request.getRealPath ( "/ article/article5a/example/filetest");
File d = new File (path); / / set up the current directory in the File object files
File list [] = d.listFiles ();// made on behalf of all the files in the directory object array File
Out.println ( "" + path + "directory paper:
");
For (int i = 0; i
Out.println (list [i]. GetName () + "
");
)
)
Out.println ( "
"+ Path +" directory under the directory:
");
For (int i = 0; i
Out.println (list [i]. GetName () + "
");
)
)
%>
</ Body>
</ Td> </ tr> <tr>
Carp Forum
(New) Download Address: http://www.liyunet.com/bbs/download.jsp
It also "Carp Forum," a new domain name to do that. Suggest that you use liyunet.com visit.
Add the "Report to moderator posts" function, the function for members, mainly against the illegal posting of reports and refuse to facilitate Moderators management, and increase the Tribune the involvement of members of the management.
Add "Send this page to a friend" function, to any forum that all the people can compare like to post links to their friends in the form of e-mail.
Add "the message sent packing" function, any forum here, if you want to post the text of the collection, the use of the function and the link will be posted with the text to a designated mailbox.
Add "Show Posts operating log" function, the moderator to facilitate administrator Show the management of the posts.
Add a new category within achieve JAVA MAIL email.
Add a new document type operation, generating HTML pages to achieve function.
Add User registration of users functional, try to use AJAX technology, it will be more functional use this technology to make.
Forum Member to amend repair information, exception handling and has not closed the database connection problems.
Manage Forum repair update data interface errors.
Revising internal category BUG.
Pages and the prospects of doing a simple easy-to-use changes.
MySQL4.1 or later there could be garbled question, please "carp forum," and "e-commerce technology" view, there are issues to resolve hash related articles.
In the process such as the use of other issues, go to the section of the postings, I will try my best to help you solve!
Chinese carp forum to the relevant Description: http://www.liyunet.com/bbs/dispbbs.jsp?forumID=2&rootID=551&announceID=551
List of repair due to the Forum cache dished out anomalies and individual errors
Removed in the list pages Member List, only shows the number of major information, and save resources for the provision of "online" links
List of the show online repair the problem hash
Home repair show officers in the list, "the current position" hash, and the user-level display hash issues
Home plate repair the left picture, as a new cache posts the same question
Posts pages repair show "indicates the print version of" functional errors
Restoration of the "Add Favorites" function mistakes
Add repair and modify the background section of the show features the wrong picture
The cache repair the problem, not the background changes to update the information forum issues
Repair transformation in the use of coding, the moderator announced hash issues
Repair the original forum posts can not be imported single quotes problems
Repair Forum Highlights page list of issues
Repair after posting back page heading shows that the problem can not be normal
Add Tour Posts, "a theme" and "Next" feature
Finishing prospects code JSP and JAVA class file format, aimed at improving efficiency
……
Some small changes not individually listed.
Because the system can be configured to write the data into whether or Douchushuju before the coding conversion, in what format conversion to another kind of what kind of format.
Therefore, we must better use of the Forum, please read the following documents.
Modify / WEB-INF/systemconfig.properties documents
# Convert param encoding - ParamUtil.get * Parameter ()
Param = no
Param.from = ISO-8859-1
Param.to = GBK
Yes can be of no
# #
# Convert encoding - ParamUtil.get * Parameter ()
# #
Encode = no
Encode.from = ISO-8859-1
Encode.to = GBK
Yes can be of no
# SqlQuery.get * ()
Decode = no
Decode.from = ISO-8859-1
Decode.to = GBK
Yes can be of no
If there is to http://bbs.on-ly.com Chinese problems can be posted to the Forum!
And the process of decentralization RESIN WEBAPPS directory.
Open sites.
2, built-in a preliminary package of JDBC components to enhance the control of the data, paging, from limited data, and other coding into more convenient API!
3, the middle layers of data OSCache object cache, support EHCACHE!
4, related tools category, the use of developing more convenient, fast!
5, pages of the application OSCache cache.
6, page-refresh prospects.
↑ Back