package net.caiban.utils.file;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/**
* @author mays
*
*/
@Deprecated
public class FileUtil {
@SuppressWarnings("rawtypes")
public static Map<String, String> readPropertyFile(String file,String charsetName) throws IOException {
if (charsetName==null || charsetName.trim().length()==0){
charsetName="gbk";
}
Map<String, String> map = new HashMap<String, String>();
InputStream is =null;
if(file.startsWith("file:"))
is=new FileInputStream(new File(file.substring(5)));
else
is=FileUtil.class.getClassLoader().getResourceAsStream(file);
Properties properties = new Properties();
properties.load(is);
Enumeration en = properties.propertyNames();
while (en.hasMoreElements()) {
String key = (String) en.nextElement();
String code = new String(properties.getProperty(key).getBytes(
"ISO-8859-1"), charsetName);
map.put(key, code);
}
return map;
}
}