package colections;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Properties;
public class ReadNdStoreProps {
public static void main(String[] args) throws IOException, SQLException {
Properties p = new Properties();
//by using fis or fr we can read file and store it into properties using load and then we can use them across the bean
// FileInputStream fis = new FileInputStream("R:\\Bore\\Eclipse Workspace\\Testing\\src\\colections\\login.txt");
FileReader fr = new FileReader("R:\\Bore\\Eclipse Workspace\\Testing\\src\\colections\\login.txt");
p.load(fr);
String url = p.getProperty("url");
String user = p.getProperty("user");
String pswd = p.getProperty("pswd");
//by using newline or "\n" we can separate lines
String newLine = System.getProperty("line.separator");
System.out.println(url+newLine+user+" \n"+pswd);
fr.close();
}
}
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Properties;
public class ReadNdStoreProps {
public static void main(String[] args) throws IOException, SQLException {
Properties p = new Properties();
//by using fis or fr we can read file and store it into properties using load and then we can use them across the bean
// FileInputStream fis = new FileInputStream("R:\\Bore\\Eclipse Workspace\\Testing\\src\\colections\\login.txt");
FileReader fr = new FileReader("R:\\Bore\\Eclipse Workspace\\Testing\\src\\colections\\login.txt");
p.load(fr);
String url = p.getProperty("url");
String user = p.getProperty("user");
String pswd = p.getProperty("pswd");
//by using newline or "\n" we can separate lines
String newLine = System.getProperty("line.separator");
System.out.println(url+newLine+user+" \n"+pswd);
fr.close();
}
}
No comments:
Post a Comment