/*A class containing methods useful for manipulatingText Files1. readfilebyline:Reads the contents of a text file line by lineAnd returns a string array representation, whereEach line is stored in an element of the array.2. readfileRead the contents of a text file into a string*/
Import java. Io .*;Import java. util .*
With @propertysource, you can specify the read configuration file and get the value by @value annotations, using: PackageCN.QLQ;ImportOrg.springframework.context.annotation.Bean;ImportOrg.springframework.context.annotation.ComponentScan;Importorg.springframework.context.annotation.Configuration;ImportOrg.springframework.context.annotation.PropertySource; @Configuration//This annotation indicates that the cl
private void FileReader () throws ioexception{BufferedReader bf= New BufferedReader (New InputStreamReader (New FileInputStream ("d:\\comparedll.py"), "UTF-8");String str= "";while ((Str=bf.readline ())!=null) {System.out.println (str);}Bf.close ();}If you do not specify the encoding, the system default encoding is used when reading the file, typically GBKI/O class handling for JavaThe reader class is the parent of the
in the real work, we often need to save some system configuration information, we generally will choose to complete the configuration file, this article according to the author's work to read the configuration file of a small sum, the main description is spring read the configuration
Tool class Workbookfactory/** * Creates the appropriate hssfworkbook/xssfworkbook from * The given inputstream. * Your input stream must either support mark/reset, or ' be wrapped as a {@link pushbackinputstream}! * /public static Workbook Create (InputStream inp) throws IOException, invalidformatexception { //If clearly does N ' t do mark/reset, wrap up if (! inp.marksupported ()) { INP = new Pushbackinputstream (INP, 8); } if (Poifsfilesystem.has
Today's Csdn FAQ explains how to read the contents of an XML file in Java.
Directly on the code, the note is very clear!
Copy Code code as follows:
Import java.io.*;
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
Java does not understand compression directly read the. zip compressed File This example, the following demo of the project source generation download address is as follows: Source code Download address
Package com.sd.test.readzip;
Import Java.io.BufferedInputStream;
Import Java.io.BufferedReader;
Import Java.io.FileInputStream;
Import java.io.IOException;
Imp
Content transferred from: 539006361 New Properties (); 2 InputStream is = dbutils. class. getResourceAsStream ("jdbc.properties");Find files from the class root directory as follows1 New Properties (); 2 inputstream instream= dbutil. class. getClassLoader (). getResourceAsStream ("configjdbc.properties"); 3 properties.load (instream);Here's how to find files from the package under the current class1 New Properties (); 2 inputstream instream= dbutil. class. getResourceAsStream ("configjdbc.proper
1. Configuration of perm.properties filesIapp.perm.camera= cameraiapp.perm.sms= SMS2. Read the contents of the Properties configuration file ( implemented by the getResourceAsStream (String name) method of the Java.lang.Class class )public class Test {public static void Main (string[] args) {Properties Properties = new properties ();InputStream in = Test.class.getClassLoader (). getResourceAsStream ("/perm.
Label:
Spring uses a configuration file to read Jdbc.properties
Add two required beans to the Beans.xml
[HTML]class= "Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >destroy-method= "Close" >
The jdbc.properties under the Web-inf
[HTML]Jdbc.driverclassname=com.mysql.jdbc.driverJdbc.url=jdbc:mysql://210.30.12.3:3306/springJdbc.us
Properties class inherits from HashtableIt provides several main methods:1. GetProperty (String key) that searches for properties in this property list with the specified key. That is, by the parameter key, the value corresponding to the key is obtained.2. Load (InputStream instream) to read the list of attributes (key and element pairs) from the input stream. Gets all the key-value pairs in the file by loa
Original: Java vs. io and NiO file read/write performance testSource code: Http://www.zuidaima.com/share/1550463508466688.htm1. NIO uses a way closer to the operating system to execute IO: Channels and buffers, as the name implies, data source data is transmitted by the buffer through the channel. 2. After JDK5, the raw IO system was optimized for NIO at the bott
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.