Here's the code:
Properties prop = new Properties();
FileInputStream fis = new FileInputStream("src/prop.txt");
//Read the content
byte[] bys = new byte[1024];
int len;
while((len=fis.read(bys))!=-1) {
System.out.println(new String(bys));
}
//Load the properties and print
prop.load(fis);
fis.close();
System.out.println(prop);
The src/prop.txt is simple as:
city=LA
country=USA
It prints out nothing in the prop, meaning the prop is empty:
{}
But if I remove the part of reading, prop can be loaded as:
{country=USA, city=LA}
Why is it failed to fulfill the prop after reading the content of prop.txt?