以下是我在applet中调用的Hello类,webServerStr路径是由文件中读的,
运行时系统抛出例外,说没有读webserver.prop的权限,该怎么办啊?import java.util.*;
import java.io.*;
import java.net.*;
import java.util.Properties;public class Hello { public static Properties settings = getServerInfo();
public static String hostName = settings.getProperty("HOSTNAME");
public static String port = settings.getProperty("PORT");
public static String servletPath = settings.getProperty("SERVLETPATH"); private static String webServerStr = "http://" + hostName + ":" + port + servletPath; /**
* get the MonModel object
*/ public static Properties getServerInfo(){
Properties defaultSettings=new Properties();
defaultSettings.put("HOSTNAME","192.168.100.219");
defaultSettings.put("PORT","9080");
defaultSettings.put("SERVLETPATH","/Monitor/MonServlet"); Properties settings=new Properties(defaultSettings);
try{
FilePermission perm = new FilePermission (".\\*", "read");
FileInputStream sf=new FileInputStream("webserver.prop");
settings.load(sf); }catch(FileNotFoundException e){ System.out.println("Properties File webserver not found!"); }
catch(IOException e) { System.out.println("IOException is found!"); }
return settings;
}}
运行时系统抛出例外,说没有读webserver.prop的权限,该怎么办啊?import java.util.*;
import java.io.*;
import java.net.*;
import java.util.Properties;public class Hello { public static Properties settings = getServerInfo();
public static String hostName = settings.getProperty("HOSTNAME");
public static String port = settings.getProperty("PORT");
public static String servletPath = settings.getProperty("SERVLETPATH"); private static String webServerStr = "http://" + hostName + ":" + port + servletPath; /**
* get the MonModel object
*/ public static Properties getServerInfo(){
Properties defaultSettings=new Properties();
defaultSettings.put("HOSTNAME","192.168.100.219");
defaultSettings.put("PORT","9080");
defaultSettings.put("SERVLETPATH","/Monitor/MonServlet"); Properties settings=new Properties(defaultSettings);
try{
FilePermission perm = new FilePermission (".\\*", "read");
FileInputStream sf=new FileInputStream("webserver.prop");
settings.load(sf); }catch(FileNotFoundException e){ System.out.println("Properties File webserver not found!"); }
catch(IOException e) { System.out.println("IOException is found!"); }
return settings;
}}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货