/** * Gets the resource's inputstream. * * @param key the full name of the resource. * @return the {@code InputStream} to get the resource or {@code null} if not found. */ public static InputStream getResourceStream(String key) { return getResourceStream(key, null); }
/** * Gets the resource's inputstream. * * @param key the full name of the resource. * @return the {@code InputStream} to get the resource or {@code null} if not found. */ public static InputStream getResourceStream(String key) { return getResourceStream(key, null); }
private static void loadRegistry() throws java.io.IOException { InputStream resource = ResourceUtil.getResourceStream(FontResources.CMAPS + "cjk_registry.properties"); Properties p = new Properties(); p.load(resource); resource.close(); for (Object key : p.keySet()) { String value = p.getProperty((String)key); String[] sp = value.split(" "); Set<String> hs = new HashSet<String>(); for (String s : sp) { if (s.length() > 0) hs.add(s); } registryNames.put((String)key, hs); } }
private static void loadRegistry() throws java.io.IOException { InputStream resource = ResourceUtil.getResourceStream(FontResources.CMAPS + "cjk_registry.properties"); Properties p = new Properties(); p.load(resource); resource.close(); for (Object key : p.keySet()) { String value = p.getProperty((String)key); String[] sp = value.split(" "); Set<String> hs = new HashSet<String>(); for (String s : sp) { if (s.length() > 0) hs.add(s); } registryNames.put((String)key, hs); } }
/** @throws SAXException if not caught */ protected void getExternalClasses() throws SAXException { XMLReader mainParser = parser; parser = createParser(); parser.setContentHandler(this); parser.setErrorHandler(this); InputStream stream = ResourceUtil.getResourceStream(HyphenationConstants.HYPHENATION_DEFAULT_RESOURCE + "external/classes.xml"); InputSource source = new InputSource(stream); try { parser.parse(source); } catch (IOException ioe) { throw new SAXException(ioe.getMessage()); } finally { parser = mainParser; } }
/** * Creates a SvgStyleResolver. */ public SvgStyleResolver() { try (InputStream defaultCss = ResourceUtil.getResourceStream(DEFAULT_CSS_PATH)) { this.css = CssStyleSheetParser.parse(defaultCss); } catch (IOException e) { Logger logger = LoggerFactory.getLogger(this.getClass()); logger.warn(SvgLogMessageConstant.ERROR_INITIALIZING_DEFAULT_CSS, e); this.css = new CssStyleSheet(); } }
/** @throws SAXException if not caught */ protected void getExternalClasses() throws SAXException { XMLReader mainParser = parser; parser = createParser(); parser.setContentHandler(this); parser.setErrorHandler(this); InputStream stream = ResourceUtil.getResourceStream(HyphenationConstants.HYPHENATION_DEFAULT_RESOURCE + "external/classes.xml"); InputSource source = new InputSource(stream); try { parser.parse(source); } catch (IOException ioe) { throw new SAXException(ioe.getMessage()); } finally { parser = mainParser; } }
private static void loadRegistry() throws java.io.IOException { InputStream resource = ResourceUtil.getResourceStream(FontResources.CMAPS + CJK_REGISTRY_FILENAME); try { Properties p = new Properties(); p.load(resource); for (Map.Entry<Object, Object> entry : p.entrySet()) { String value = (String) entry.getValue(); String[] splitValue = value.split(" "); Set<String> set = new HashSet<>(); for (String s : splitValue) { if (s.length() != 0) { set.add(s); } } registryNames.put((String) entry.getKey(), set); } } finally { if (resource != null) { resource.close(); } } }
private static void loadRegistry() throws java.io.IOException { InputStream resource = ResourceUtil.getResourceStream(FontResources.CMAPS + CJK_REGISTRY_FILENAME); try { Properties p = new Properties(); p.load(resource); for (Map.Entry<Object, Object> entry : p.entrySet()) { String value = (String) entry.getValue(); String[] splitValue = value.split(" "); Set<String> set = new HashSet<>(); for (String s : splitValue) { if (s.length() != 0) { set.add(s); } } registryNames.put((String) entry.getKey(), set); } } finally { if (resource != null) { resource.close(); } } }
private static Map<String, Object> readFontProperties(String name) throws java.io.IOException { name += ".properties"; InputStream resource = ResourceUtil.getResourceStream(FontResources.CMAPS + name); Properties p = new Properties(); p.load(resource); resource.close(); IntHashtable W = createMetric(p.getProperty("W")); p.remove("W"); IntHashtable W2 = createMetric(p.getProperty("W2")); p.remove("W2"); Map<String, Object> map = new HashMap<String, Object>(); for (Object obj : p.keySet()) { map.put((String)obj, p.getProperty((String)obj)); } map.put("W", W); map.put("W2", W2); return map; }
private static Map<String, Object> readFontProperties(String name) throws java.io.IOException { InputStream resource = ResourceUtil.getResourceStream(FontResources.CMAPS + name + ".properties"); try { Properties p = new Properties(); p.load(resource); Map<String, Object> fontProperties = new HashMap<>(); for (Map.Entry<Object, Object> entry : p.entrySet()) { fontProperties.put((String) entry.getKey(), entry.getValue()); } fontProperties.put(W_PROP, createMetric((String) fontProperties.get(W_PROP))); fontProperties.put(W2_PROP, createMetric((String) fontProperties.get(W2_PROP))); return fontProperties; } finally { if (resource != null) { resource.close(); } } }
private static Map<String, Object> readFontProperties(String name) throws java.io.IOException { InputStream resource = ResourceUtil.getResourceStream(FontResources.CMAPS + name + ".properties"); try { Properties p = new Properties(); p.load(resource); Map<String, Object> fontProperties = new HashMap<>(); for (Map.Entry<Object, Object> entry : p.entrySet()) { fontProperties.put((String) entry.getKey(), entry.getValue()); } fontProperties.put(W_PROP, createMetric((String) fontProperties.get(W_PROP))); fontProperties.put(W2_PROP, createMetric((String) fontProperties.get(W2_PROP))); return fontProperties; } finally { if (resource != null) { resource.close(); } } }
private static Map<String, Object> readFontProperties(String name) throws java.io.IOException { name += ".properties"; InputStream resource = ResourceUtil.getResourceStream(FontResources.CMAPS + name); Properties p = new Properties(); p.load(resource); resource.close(); IntHashtable W = createMetric(p.getProperty("W")); p.remove("W"); IntHashtable W2 = createMetric(p.getProperty("W2")); p.remove("W2"); Map<String, Object> map = new HashMap<String, Object>(); for (Object obj : p.keySet()) { map.put((String)obj, p.getProperty((String)obj)); } map.put("W", W); map.put("W2", W2); return map; }
/** * Creates a new {@link IRandomAccessSource} by reading the specified file/resource into memory * @param filename the name of the resource to read * @return the newly created {@link IRandomAccessSource} * @throws java.io.IOException if reading the underling file or stream fails */ private IRandomAccessSource createByReadingToMemory(String filename) throws java.io.IOException { InputStream stream = ResourceUtil.getResourceStream(filename); if (stream == null) { throw new java.io.IOException(MessageFormatUtil.format(IOException._1NotFoundAsFileOrResource, filename)); } return createByReadingToMemory(stream); }
/** * Creates a new {@link IRandomAccessSource} by reading the specified file/resource into memory * @param filename the name of the resource to read * @return the newly created {@link IRandomAccessSource} * @throws java.io.IOException if reading the underling file or stream fails */ private IRandomAccessSource createByReadingToMemory(String filename) throws java.io.IOException { InputStream stream = ResourceUtil.getResourceStream(filename); if (stream == null) { throw new java.io.IOException(MessageFormatUtil.format(IOException._1NotFoundAsFileOrResource, filename)); } return createByReadingToMemory(stream); }
try { String resourcePath = FontResources.AFMS + afmPath + ".afm"; resource = ResourceUtil.getResourceStream(resourcePath); if (resource == null) { throw new IOException("{0} was not found as resource.").setMessageParams(resourcePath);
try { String resourcePath = FontResources.AFMS + afmPath + ".afm"; resource = ResourceUtil.getResourceStream(resourcePath); if (resource == null) { throw new IOException("{0} was not found as resource.").setMessageParams(resourcePath);
@Override public PdfTokenizer getLocation(String location) throws java.io.IOException { String fullName = FontResources.CMAPS + location; InputStream inp = ResourceUtil.getResourceStream(fullName); if (inp == null) { throw new IOException(IOException.Cmap1WasNotFound).setMessageParams(fullName); } return new PdfTokenizer(new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(inp))); } }
@Override public PdfTokenizer getLocation(String location) throws java.io.IOException { String fullName = FontResources.CMAPS + location; InputStream inp = ResourceUtil.getResourceStream(fullName); if (inp == null) { throw new IOException(IOException.Cmap1WasNotFound).setMessageParams(fullName); } return new PdfTokenizer(new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(inp))); } }
InputStream defaultHyphenationResourceStream = ResourceUtil.getResourceStream(HyphenationConstants.HYPHENATION_DEFAULT_RESOURCE + key + ".xml"); if (defaultHyphenationResourceStream != null) { hTree = getHyphenationTree(defaultHyphenationResourceStream, key);