diff options
2 files changed, 26 insertions, 24 deletions
diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java index 5c8bd6af0624..c43200744e15 100644 --- a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java +++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java @@ -69,24 +69,25 @@ public class ScriptEditorForBeanShell implements ScriptEditor, ActionListener { // try to load the template for BeanShell scripts static { + BSHTEMPLATE = "// BeanShell script"; try { URL url = ScriptEditorForBeanShell.class.getResource("template.bsh"); - InputStream in = url.openStream(); - StringBuilder buf = new StringBuilder(); - byte[] b = new byte[1024]; - int len; - - while ((len = in.read(b)) != -1) { - buf.append(new String(b, 0, len)); - } + if (url != null) { + InputStream in = url.openStream(); + StringBuilder buf = new StringBuilder(); + byte[] b = new byte[1024]; + int len; + + while ((len = in.read(b)) != -1) { + buf.append(new String(b, 0, len)); + } - in.close(); + in.close(); - BSHTEMPLATE = buf.toString(); + BSHTEMPLATE = buf.toString(); + } } catch (IOException ioe) { - BSHTEMPLATE = "// BeanShell script"; } catch (Exception e) { - BSHTEMPLATE = "// BeanShell script"; } } diff --git a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java index 755086d4daf2..a43abc25f7cd 100644 --- a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java +++ b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java @@ -55,24 +55,25 @@ public class ScriptEditorForJavaScript implements ScriptEditor { HashMap<String, ScriptEditorForJavaScript>(); static { + JSTEMPLATE = "// JavaScript script"; try { URL url = ScriptEditorForJavaScript.class.getResource("template.js"); - InputStream in = url.openStream(); - StringBuilder buf = new StringBuilder(); - byte[] b = new byte[1024]; - int len; - - while ((len = in.read(b)) != -1) { - buf.append(new String(b, 0, len)); - } + if (url != null) { + InputStream in = url.openStream(); + StringBuilder buf = new StringBuilder(); + byte[] b = new byte[1024]; + int len; + + while ((len = in.read(b)) != -1) { + buf.append(new String(b, 0, len)); + } - in.close(); + in.close(); - JSTEMPLATE = buf.toString(); + JSTEMPLATE = buf.toString(); + } } catch (IOException ioe) { - JSTEMPLATE = "// JavaScript script"; } catch (Exception e) { - JSTEMPLATE = "// JavaScript script"; } } |