Java.util.Properties.load(InputStream inStream) Method Example
JAVA.UTIL.PROPERTIES.LOAD METHOD
Copyright ?
Description
The java.util.Properties.loadInputStreaminStream method reads a property list keyandelementpairs from the input byte stream. The input stream is in a simple line-oriented format as specified in loadReader and is assumed to use the ISO 8859-1 character encoding; that is each byte is one Latin1 character.
Declaration
Following is the declaration for java.util.Properties.load method
public void load(InputStream inStream)
Parameters
inStream -- the input stream.
Return Value
This method does not return a value.
Exception
IOException -- if an error occurred when reading from the input stream.
IllegalArgumentException -- if the input stream contains a malformed Unicode escape sequence.
Example
The following example shows the usage of java.util.Properties.list method.
package com.tutorialspoint;
import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.*;
public class PropertiesDemo {
public static void main(String[] args) { Properties prop = new Properties(); String s = "Height=200"; String s2 = "Width=15";
try {
// create a new input and output stream FileOutputStream fos = new FileOutputStream("properties.txt"); FileInputStream fis = new FileInputStream("properties.txt");
// write the first property in the output stream file fos.write(s.getBytes());
// change the line between the two properties fos.write("\n".getBytes());
// write next property fos.write(s2.getBytes());
// load from input stream prop.load(fis);
// print the properties list from System.out prop.list(System .out);
} catch (IOException ex) { ex.printStackTrace(); } } }
Let us compile and run the above program, this will produce the following result:
-- listing properties -Width=15 Height=200
Loading [MathJax]/jax/output/HTML-CSS/jax.js
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- java files copyright © tutorialspoint
- exploring java i o unit 4 exploring java i o
- serial communication in java with example program idc online
- java s input output github pages
- long n method example tutorialspoint
- intermediate programming adelphi university
- java files and i o
- input output classes java and oop
- chapter 20 streams and binary input output
- binary i o university of california san diego
Related searches
- java array example code
- java example code for beginners
- example of java program
- example java code hello world
- java class example code
- java copy inputstream to file
- java write inputstream to file
- string to java util date
- arraylist java exam example code
- java arraylist example code
- properties of exponents example problems
- java get calling method name