关于GRAL安装中super()关键字和.properties文件的JAVA问题
作为一名JAVA初学者,我尝试通过教程使用。我犯了以下错误:关于GRAL安装中super()关键字和.properties文件的JAVA问题,java,properties,runtime,super,Java,Properties,Runtime,Super,作为一名JAVA初学者,我尝试通过教程使用。我犯了以下错误: java.lang.RuntimeException: java.io.IOException: Property file not found: drawablewriters.properties 此运行时错误来自以下未更改的GRAL源代码行: public final class DrawableWriterFactory extends AbstractIOFactory<DrawableWriter> { /
java.lang.RuntimeException: java.io.IOException: Property file not found: drawablewriters.properties
此运行时错误来自以下未更改的GRAL源代码行:
public final class DrawableWriterFactory extends AbstractIOFactory<DrawableWriter> {
/** Singleton instance. */
private static DrawableWriterFactory instance;
/**
* Constructor that initializes the factory.
* @throws IOException if the properties file could not be found.
*/
private DrawableWriterFactory() throws IOException {
super("drawablewriters.properties"); //$NON-NLS-1$
}
/**
* Returns an instance of this DrawableWriterFactory.
* @return Instance.
*/
public static DrawableWriterFactory getInstance() {
if (instance == null) {
try {
instance = new DrawableWriterFactory();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return instance;
}
公共最终类DrawableWriterFactory扩展了AbstractIOFactory{
/**单例实例*/
私有静态DrawableWriterFactory实例;
/**
*初始化工厂的构造函数。
*@如果找不到属性文件,则引发IOException。
*/
私有DrawableWriterFactory()引发IOException{
超级(“drawablewriters.properties”);//$NON-NLS-1$
}
/**
*返回此DrawableWriterFactory的实例。
*@return实例。
*/
公共静态DrawableWriterFactory getInstance(){
if(实例==null){
试一试{
实例=新的DrawableWriterFactory();
}捕获(IOE异常){
抛出新的运行时异常(e);
}
}
返回实例;
}
上面的类是另一个类中的引用,该类引用了最初运行的代码
在阅读了关键字之后,super似乎永远不会在构造函数中使用.properties文件作为参数。在这种情况下,它如何使用.properties文件
我在下面的文章中注意到,新的InputStream通常用于提取.properties文件的内容
此外,我只是尝试将drawablewriters.properties与上面的源代码放在同一个目录中。但没有成功。语法super(“drawablewriters.properties”);
仅仅是对此类超类构造函数的调用。它可以具有由其中一个超类构造函数获取的任何参数。在这种情况下,它调用的是AbstractIOFactory
的构造函数
您案例中的问题是文件DrawableWriter.properties
不是超类构造函数可以找到的地方。您应该查看AbstractIOFactory
的文档,了解它如何解析属性文件名