package test;



import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ReadProperties {
	

	public static void main(String[] args) {
		String s=ReadProperties.GetTestPropertyByKey("xls");
		System.out.println(s);
//		ClearProperty();
//		SetProperty("123","111");
	}
	
    public static String GetPropertyByKey(String key) {
        Properties pps = new Properties();
        try {
        	File directory = new File(".");
            String sourceFile = directory.getCanonicalPath() +File.separator+"src"+File.separator+"resources"+File.separator+"class.properties";
            InputStream in = new BufferedInputStream (new FileInputStream(sourceFile));  
            pps.load(in);
            String value = pps.getProperty(key);
            return value;
        }catch (IOException e) {
            return null;
        }
    }
    
    public static String GetTestPropertyByKey(String key) {
        Properties pps = new Properties();
        try {
        	File directory = new File(".");
        	System.out.println(directory);
        	
            String sourceFile = directory.getCanonicalPath() +File.separator+"src"+File.separator+"resources"+File.separator+"test.properties";
          
            InputStream in = new BufferedInputStream (new FileInputStream(sourceFile));  
            pps.load(in);
            String value = pps.getProperty(key);
            System.out.println("value====" +value);
            return value;
        }catch (IOException e) {
            return null;
        }
    }
 }
    