Java 当getResource()给出错误时,如何获取属性文件的outputStream?
早上好,这是我的方法Java 当getResource()给出错误时,如何获取属性文件的outputStream?,java,properties,outputstream,Java,Properties,Outputstream,早上好,这是我的方法 public void updatePropertiyByValue(String key, String value, String propFile) throws IOException { Properties prop = new Properties(); objClassLoader = getClass().getClassLoader(); InputStream objFileInp
public void updatePropertiyByValue(String key, String value, String propFile) throws IOException {
Properties prop = new Properties();
objClassLoader = getClass().getClassLoader();
InputStream objFileInputStream = null;
objFileInputStream = getClass().getClassLoader().getResourceAsStream(propFile);
prop.load(objFileInputStream);
objFileInputStream.close();
OutputStream output = null;
try {
output = new FileOutputStream(objClassLoader.getResource(propFile).getFile());
prop.setProperty(key, value);
prop.store(output, null);
}catch (Exception e) {
e.printStackTrace();
}finally {
output.close();
}
}
它的工作是更新属性文件。我的问题是inputStream与getResourceAsStream(propFile)
配合得很好,而Output部分给了我一个错误:
java.io.FileNotFoundException: file:*********************************\easyDeployment\EasyDeployment\target\EasyDeployment-0.0.1-SNAPSHOT.jar!\configuration.properties (The syntax of the file name, the directory name or the value label is not correct) // translated from my native language
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at Configuration.PropertiesMenager.updatePropertiyByValue(PropertiesMenager.java:58)
at GraphicInterface.GInterface$3.actionPerformed(GInterface.java:328)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Configuration.PropertiesMenager.updatePropertiyByValue(PropertiesMenager.java:64)
at GraphicInterface.GInterface$3.actionPerformed(GInterface.java:328)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
java.io.FileNotFoundException:文件:******************************************\easyDeployment\easyDeployment\target\easyDeployment-0.0.1-SNAPSHOT.jar\configuration.properties(文件名、目录名或值标签的语法不正确)//从我的母语翻译过来
位于java.io.FileOutputStream.open0(本机方法)
位于java.io.FileOutputStream.open(未知源代码)
位于java.io.FileOutputStream。(未知源)
位于java.io.FileOutputStream。(未知源)
在Configuration.PropertiesMenager.updatePropertityByValue(PropertiesMenager.java:58)中
在GraphicInterface.GInterface$3.actionPerformed(GInterface.java:328)
在javax.swing.AbstractButton.fireActionPerformed(未知源)
位于javax.swing.AbstractButton$Handler.actionPerformed(未知源)
在javax.swing.DefaultButtonModel.fireActionPerformed(未知源)
位于javax.swing.DefaultButtonModel.setPressed(未知源)
位于javax.swing.plaf.basic.BasicButtonListener.mouseReleased(未知源代码)
位于java.awt.Component.ProcessMouseeEvent(未知源)
位于javax.swing.JComponent.ProcessMouseeEvent(未知源)
位于java.awt.Component.processEvent(未知源)
位于java.awt.Container.processEvent(未知源)
位于java.awt.Component.dispatchEventImpl(未知源)
位于java.awt.Container.dispatchEventImpl(未知源)
位于java.awt.Component.dispatchEvent(未知源)
位于java.awt.LightweightDispatcher.RetargetMouseeEvent(未知源)
位于java.awt.LightweightDispatcher.ProcessMouseeEvent(未知源)
位于java.awt.LightweightDispatcher.dispatchEvent(未知源)
位于java.awt.Container.dispatchEventImpl(未知源)
位于java.awt.Window.dispatchEventImpl(未知源)
位于java.awt.Component.dispatchEvent(未知源)
位于java.awt.EventQueue.dispatchEventImpl(未知源)
位于java.awt.EventQueue.access$500(未知源)
在java.awt.EventQueue$3.run处(未知源)
在java.awt.EventQueue$3.run处(未知源)
位于java.security.AccessController.doPrivileged(本机方法)
位于java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(未知源)
位于java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(未知源)
在java.awt.EventQueue$4.run处(未知源)
在java.awt.EventQueue$4.run处(未知源)
位于java.security.AccessController.doPrivileged(本机方法)
位于java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(未知源)
位于java.awt.EventQueue.dispatchEvent(未知源)
位于java.awt.EventDispatchThread.pumpOneEventForFilters(未知源)
位于java.awt.EventDispatchThread.pumpEventsForFilter(未知源)
位于java.awt.EventDispatchThread.pumpEventsForHierarchy(未知源)
位于java.awt.EventDispatchThread.pumpEvents(未知源)
位于java.awt.EventDispatchThread.pumpEvents(未知源)
位于java.awt.EventDispatchThread.run(未知源)
线程“AWT-EventQueue-0”java.lang.NullPointerException中出现异常
在Configuration.PropertiesMenager.updatePropertityByValue(PropertiesMenager.java:64)处
在GraphicInterface.GInterface$3.actionPerformed(GInterface.java:328)
在javax.swing.AbstractButton.fireActionPerformed(未知源)
位于javax.swing.AbstractButton$Handler.actionPerformed(未知源)
在javax.swing.DefaultButtonModel.fireActionPerformed(未知源)
位于javax.swing.DefaultButtonModel.setPressed(未知源)
位于javax.swing.plaf.basic.BasicButtonListener.mouseReleased(未知源代码)
位于java.awt.Component.ProcessMouseeEvent(未知源)
位于javax.swing.JComponent.ProcessMouseeEvent(未知源)
位于java.awt.Component.processEvent(未知源)
位于java.awt.Container.processEvent(未知源)
位于java.awt.Component.dispatchEventImpl(未知源)
位于java.awt.Container.dispatchEventImpl(未知源)
位于java.awt.Component.dispatchEvent(未知源)
位于java.awt.LightweightDispatcher.RetargetMouseeEvent(未知源)
位于java.awt.LightweightDispatcher.ProcessMouseeEvent(未知源)
位于java.awt.LightweightDispatcher.dispatchEvent(未知源)
位于java.awt.Container.dispatchEventImpl(未知源)
位于java.awt.Window.dispatchEventImpl(未知源)
位于java.awt.Component.dispatchEvent(未知源)
位于java.awt.EventQueue.dispatchEventImpl(未知源)
位于java.awt.EventQueue.access$500(未知源)
在java.awt.EventQueue$3.run处(未知源)
在java.awt.EventQueue$3.run处(未知源)
位于java.security.AccessController.doPrivileged(本机方法)
位于java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(未知源)
位于java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(未知源)
在java.awt.EventQueue$4.run处(未知源)
在java.awt.EventQueue$4.run处(未知源)
位于java.security.AccessController.doPrivileged(本机方法)
位于java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(未知源)
位于java.awt.EventQueue.dispatchEvent(未知源)
位于java.awt.EventDispatchThread.pumpOneEventForFilters(未知源)
位于java.awt.EventDispatchThread.pumpEventsForFilter(未知源)
在java.a