directory for the log fileString fname = Directory.GetCurrentDirectory () + "\\LogFile.txt";/**/Defining File Information objectsFileInfo finfo = new FileInfo (fname);if (!finfo. Exists){FileStream FS;FS = File.create (fname);Fs. Close ();Finfo = new FileInfo (fname);}/**/Determine if the file exists and is greater than 2Kif (finfo. Length > 1024 * 1024 * 10){/**/File
Read the picture into the DOM and save it as an XML file
1, need the name space
Using System.Text;
Using System.IO;
Using System.Xml;
2, there are 001.jpg pictures in the folder
3. Generate a Docsave.xml file
//*************************************************************************************************************
Establish a stored procedure to return the data to be read to form a result set:CREATE PROC Dbo.getvaluesfromxmlbypath@fileName NVARCHAR (128)AsDECLARE @T XML,@idoc INT,@existFlag intEXEC xp_fileexist @fileName, @existFlag OUTPUTIF @existFlag =1BEGINDECLARE @xmltab TABLE([Alias] VARCHAR (15),[ServerName] VARCHAR (15),[DatabaseName] VARCHAR (63))DECLARE @sqlCmd NVARCHAR (max) = ' SELECT @t=bulkcolumn from OP
Write the file, pass in the information to be saved *********//Save the XML-(void) SaveXML: (NSString *) data{Creating a File ManagerNsfilemanager *filemanager = [Nsfilemanager Defaultmanager];Get pathParameter nsdocumentdirectory to get that pathNsarray *paths = Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES);NSLog (@ "paths=%@",
The reference code is as follows:
Com.atguigu.struts2.app.converters.DateConverter.java
Public DateFormat GetDateFormat () {if (dateformat = =null) {// Gets the current WEB Application Initialization Parameters pattern ( This parameter is in the Web . XML file under web-inf )// get the first time you use it, and load the relevant information// This method is used /struts2-6/src/x
/*** XML read/write example * @ author HX **/public class xmlreaderwriter {/*** read an XML file, returns an employee linked list * @ Param filename * @ return */public list
public class Employee{ private long id; private String name; private boolean isMale;
To read A. xml file in. Net:1. Use the xmltextreader class, such:
Xmltextreader reader = new xmltextreader (server. mappath (xmlpath ));While (reader. Read ()){If (reader. nodetype = xmlnodetype. Text){Response. Write (reader. Name + "DD" + reader. value );}}
2. Use the xpathnavigator class:
Xpathdocument xpdoc =
1. Use the indexof () and substring () provided by the string class to quickly get specific content in a file
public static void Main (string[] args) {
//test where a word appears
String reqmessage = "
This Java implementation of the use of a simple string class to read the contents of a tag in an XML file
Attribute cls = Component.attribute ("class"); System.out.println ("[Class:]" + cls.gettext ()); Iterates through all the properties of the current component for (Iterator ite = Component.elementiterator ("property"); Ite.hasnext ();) {Element property = (Element) Ite.next (); Gets the property's name attribute and the value Attribute pname = Property.attribute ("name"); System.out.println ("[" + pname.gettext () + "]:" + prope
1. Bind dropdownlist:
Ddl_language.datasource = createdatasource ();Ddl_language.datatextfield = "languagetextfield ";Ddl_language.datavaluefield = "languagevaluefield ";Ddl_language.databind ();
2. The createdatasource () method used above:Private icollection createdatasource () {// create a data table to store the data for the ddl_langauge control datatable dt = new datatable (); // define the columns of the table DT. columns. add ("languagetextfield", typeof (string); DT. columns. add ("langu
Package test.com;Import Java.io.FileInputStream;Import Javax.xml.parsers.DocumentBuilder;Import Javax.xml.parsers.DocumentBuilderFactory;Import org.w3c.dom.Document;Import org.w3c.dom.Element;Import Org.w3c.dom.Node;Import org.w3c.dom.NodeList;public class Xmlparser {public static void Main (string[] args) throws Exception {GetXML ("Src/parameters.xml", "holdername");}/*** @desc Gets the value of the node based on the value of the key property***/public static string GetXML (string Sqlxmlpath, S
And if you use XmlReader, you do not need caching, fast reading, but if you want to query is not so convenient, do not support XPath, only through the reader () method forward loop. To avoid the disadvantages of the above two methods, come up with the following scenarios:
1, first use XmlReader to read the contents of the XML file into a linked list.
2, query
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.