void open(java.lang.String name) { final java.lang.String textString; if (name == null || name.length() == 0) { return; } java.io.File file = new java.io.File(name); if (!file.exists()) { java.lang.String message = MessageFormat.format( resources.getString("Err_file_no_exist"), new java.lang.String[] {file.getName()}); displayError(message); return; } try { java.io.FileInputStream stream = new java.io.FileInputStream(file.getPath()); try { java.io.Reader in = new java.io.BufferedReader(new java.io.InputStreamReader(stream)); char[] readBuffer = new char[2048]; java.lang.StringBuffer buffer = new java.lang.StringBuffer((int) file.length()); int n; while ((n = in.read(readBuffer)) > 0) { buffer.append(readBuffer, 0, (-n)); } textString = buffer.toString(); stream.close(); } catch (java.io.IOException e) { java.lang.String message = MessageFormat.format( resources.getString("Err_file_io"), new java.lang.String[] {file.getName()}); displayError(message); return; } } catch (java.io.FileNotFoundException e) { java.lang.String message = MessageFormat.format( resources.getString("Err_not_found"), new java.lang.String[] {file.getName()}); displayError(message); return; } org.eclipse.swt.widgets.Display display = text.getDisplay(); display.asyncExec( new java.lang.Runnable() { public void run() { text.setText(textString); } }); lineStyler.parseBlockComments(textString); }
public java.lang.String getResourceString(java.lang.String key, java.lang.Object[] args) { try { return MessageFormat.format(getResourceString(key), args); } catch (java.util.MissingResourceException e) { return key; } catch (java.lang.NullPointerException e) { return "!" + key + "!"; } }
/** * Gets a string from the resource bundle and binds it with the given arguments. If the key is not * found, return the key. */ static String getResourceString(String key, Object[] args) { try { return MessageFormat.format(getResourceString(key), args); } catch (MissingResourceException e) { return key; } catch (NullPointerException e) { return "!" + key + "!"; // $NON-NLS-1$ //$NON-NLS-2$ } }