private static Image loadImage(String name) { try { byte[] imageData = Utils.getResource(name); if (imageData == null) { return null; } return Toolkit.getDefaultToolkit().createImage(imageData); } catch (IOException e) { e.printStackTrace(); return null; } }
private Properties getResources() { if (resources == null) { resources = new Properties(); String resourceName = "/org/h2/res/javadoc.properties"; try { byte[] buff = Utils.getResource(resourceName); if (buff != null) { resources.load(new ByteArrayInputStream(buff)); } } catch (IOException e) { // ignore } } return resources; }
/** * Print the usage of the tool. This method reads the description from the * resource file. */ protected void showUsage() { if (resources == null) { resources = new Properties(); String resourceName = "/org/h2/res/javadoc.properties"; try { byte[] buff = Utils.getResource(resourceName); if (buff != null) { resources.load(new ByteArrayInputStream(buff)); } } catch (IOException e) { out.println("Cannot load " + resourceName); } } String className = getClass().getName(); out.println(resources.get(className)); out.println("Usage: java "+getClass().getName() + " <options>"); out.println(resources.get(className + ".main")); out.println("See also http://h2database.com/javadoc/" + className.replace('.', '/') + ".html"); }
/** * Create an instance using the grammar specified in the CSV file. * * @param csv if not specified, the help.csv is used * @return a new instance */ public static Bnf getInstance(Reader csv) throws SQLException, IOException { Bnf bnf = new Bnf(); if (csv == null) { byte[] data = Utils.getResource("/org/h2/res/help.csv"); csv = new InputStreamReader(new ByteArrayInputStream(data)); } bnf.parse(csv); return bnf; }
private static void installPgCatalog(Statement stat) throws SQLException { try (Reader r = new InputStreamReader(new ByteArrayInputStream(Utils .getResource("/org/h2/server/pg/pg_catalog.sql")))) { ScriptReader reader = new ScriptReader(r); while (true) { String sql = reader.readStatement(); if (sql == null) { break; } stat.execute(sql); } reader.close(); } catch (IOException e) { throw DbException.convertIOException(e, "Can not read pg_catalog resource"); } }
/** * Read the given file from the file system or from the resources. * * @param file the file name * @return the data */ byte[] getFile(String file) throws IOException { trace("getFile <" + file + ">"); byte[] data = Utils.getResource("/org/h2/server/web/res/" + file); if (data == null) { trace(" null"); } else { trace(" size=" + data.length); } return data; }
String resource = "/org/h2/res/help.csv"; try { byte[] data = Utils.getResource(resource); Reader reader = new InputStreamReader( new ByteArrayInputStream(data));
private static Image loadImage(String name) { try { byte[] imageData = Utils.getResource(name); if (imageData == null) { return null; } return Toolkit.getDefaultToolkit().createImage(imageData); } catch (IOException e) { e.printStackTrace(); return null; } }
private static Image loadImage(String name) { try { byte[] imageData = Utils.getResource(name); if (imageData == null) { return null; } return Toolkit.getDefaultToolkit().createImage(imageData); } catch (IOException e) { e.printStackTrace(); return null; } }
@Override public void decorateDatabaseInitialization(Connection connection) throws IOException, SQLException { String dbInit = new String(Utils.getResource("/org/h2/server/pg/pg_catalog.sql")); connection.prepareStatement(dbInit).execute(); } }
private Properties getResources() { if (resources == null) { resources = new Properties(); String resourceName = "/org/h2/res/javadoc.properties"; try { byte[] buff = Utils.getResource(resourceName); if (buff != null) { resources.load(new ByteArrayInputStream(buff)); } } catch (IOException e) { // ignore } } return resources; }
private Properties getResources() { if (resources == null) { resources = new Properties(); String resourceName = "/org/h2/res/javadoc.properties"; try { byte[] buff = Utils.getResource(resourceName); if (buff != null) { resources.load(new ByteArrayInputStream(buff)); } } catch (IOException e) { // ignore } } return resources; }
/** * Print the usage of the tool. This method reads the description from the * resource file. */ protected void showUsage() { if (resources == null) { resources = new Properties(); String resourceName = "/org/h2/res/javadoc.properties"; try { byte[] buff = Utils.getResource(resourceName); if (buff != null) { resources.load(new ByteArrayInputStream(buff)); } } catch (IOException e) { out.println("Cannot load " + resourceName); } } String className = getClass().getName(); out.println(resources.get(className)); out.println("Usage: java "+getClass().getName() + " <options>"); out.println(resources.get(className + ".main")); out.println("See also http://h2database.com/javadoc/" + className.replace('.', '/') + ".html"); }
/** * Print the usage of the tool. This method reads the description from the * resource file. */ protected void showUsage() { if (resources == null) { resources = new Properties(); String resourceName = "/org/h2/res/javadoc.properties"; try { byte[] buff = Utils.getResource(resourceName); if (buff != null) { resources.load(new ByteArrayInputStream(buff)); } } catch (IOException e) { out.println("Cannot load " + resourceName); } } String className = getClass().getName(); out.println(resources.get(className)); out.println("Usage: java "+getClass().getName() + " <options>"); out.println(resources.get(className + ".main")); out.println("See also http://h2database.com/javadoc/" + className.replace('.', '/') + ".html"); }
/** * Create an instance using the grammar specified in the CSV file. * * @param csv if not specified, the help.csv is used * @return a new instance */ public static Bnf getInstance(Reader csv) throws SQLException, IOException { Bnf bnf = new Bnf(); if (csv == null) { byte[] data = Utils.getResource("/org/h2/res/help.csv"); csv = new InputStreamReader(new ByteArrayInputStream(data)); } bnf.parse(csv); return bnf; }
/** * Create an instance using the grammar specified in the CSV file. * * @param csv if not specified, the help.csv is used * @return a new instance */ public static Bnf getInstance(Reader csv) throws SQLException, IOException { Bnf bnf = new Bnf(); if (csv == null) { byte[] data = Utils.getResource("/org/h2/res/help.csv"); csv = new InputStreamReader(new ByteArrayInputStream(data)); } bnf.parse(csv); return bnf; }
private static void installPgCatalog(Statement stat) throws SQLException { try (Reader r = new InputStreamReader(new ByteArrayInputStream(Utils .getResource("/org/h2/server/pg/pg_catalog.sql")))) { ScriptReader reader = new ScriptReader(r); while (true) { String sql = reader.readStatement(); if (sql == null) { break; } stat.execute(sql); } reader.close(); } catch (IOException e) { throw DbException.convertIOException(e, "Can not read pg_catalog resource"); } }
private static void installPgCatalog(Statement stat) throws SQLException { Reader r = null; try { r = new InputStreamReader(new ByteArrayInputStream(Utils .getResource("/org/h2/server/pg/pg_catalog.sql"))); ScriptReader reader = new ScriptReader(r); while (true) { String sql = reader.readStatement(); if (sql == null) { break; } stat.execute(sql); } reader.close(); } catch (IOException e) { throw DbException.convertIOException(e, "Can not read pg_catalog resource"); } finally { IOUtils.closeSilently(r); } }
/** * Read the given file from the file system or from the resources. * * @param file the file name * @return the data */ byte[] getFile(String file) throws IOException { trace("getFile <" + file + ">"); byte[] data = Utils.getResource("/org/h2/server/web/res/" + file); if (data == null) { trace(" null"); } else { trace(" size=" + data.length); } return data; }
/** * Read the given file from the file system or from the resources. * * @param file the file name * @return the data */ byte[] getFile(String file) throws IOException { trace("getFile <" + file + ">"); byte[] data = Utils.getResource("/org/h2/server/web/res/" + file); if (data == null) { trace(" null"); } else { trace(" size=" + data.length); } return data; }