package com.hr.automation.utilities;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Properties;
public class Property {
Properties props=new Properties();
String strFileName;
String strValue;
public String getProperty(String strKey) {
try{
strValue=props.getProperty(strKey);
}
catch (Exception e) {
System.out.println(e);
}
return strValue;
}
public void setProperty(String strKey,String strValue) throws Throwable {
try{
props.setProperty(strKey, strValue);
props.store(new FileOutputStream(strFileName),null);
}
catch (Exception e) {
System.out.println(e);
}
}
public void removeProperty(String strKey){
try{
props.remove(strKey);
props.store(new FileOutputStream(strFileName),null);
}
catch (Exception e) {
System.out.println(e);
}
}
public Property(String strFileName){
this.strFileName=strFileName;
System.out.println(strFileName);
File f = new File(strFileName);
if(f.exists()){
FileInputStream in = null;
try {
in = new FileInputStream(f);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
try {
props.load(in);
} catch (IOException e) {
e.printStackTrace();
}
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
else
System.out.println("File not found!");
}
// return environmental details
public static String getHostName() throws UnknownHostException{
InetAddress addr = InetAddress.getLocalHost();
//byte[] ipAddr = addr.getAddress();
String hostname = addr.getHostName();
return hostname;
}
}
Tuesday, August 30, 2016
property
Subscribe to:
Post Comments (Atom)
Thanks for Sharing Information to us. If Someone wants to know about QA and software testing this is the Right place for you...
ReplyDeleteSoftware Testing Services
Software Testing Services in India
Software Testing Companies in India
Software Testing Services in USA
Software Testing Companies in USA
Software Testing Companies
Software Testing Services Company
Software Testing Companies in New York
Independent Software Testing Services