List of usage examples for org.apache.commons.io IOUtils toCharArray
public static char[] toCharArray(Reader input) throws IOException
Reader
as a character array. From source file:org.xmlactions.pager.actions.highlighter.HighlighterAction.java
private String loadPage() throws IOException { String page = null;/* w w w .ja va 2 s. c om*/ if (getRef() != null) { page = execContext.getString(getRef()); } else { if (path == null) { path = (String) execContext.get(ActionConst.WEB_REAL_PATH_BEAN_REF); } String fileName = StrSubstitutor.replace(getFile_name(), execContext); if (path == null) { path = (String) execContext.get(ActionConst.WEB_REAL_PATH_BEAN_REF); } if (path != null) { path = StrSubstitutor.replace(getPath(), execContext); } try { page = Action.loadPage(path, fileName); } catch (IllegalArgumentException ex) { // try a load a page from a url InputStream is = null; try { URL url = new URL(fileName); if (url == null) { throw ex; } is = url.openStream(); // emm we may have an inputsteam char[] content = IOUtils.toCharArray(is); page = new String(content); } catch (Exception ignoreme) { throw ex; } } } return page; }
From source file:rubah.tools.UpdateClassGenerator.java
public void generateUpdateClass(File outJavaFile, String outJavaPackage) throws IOException { String template = new String( IOUtils.toCharArray(UpdateClassGenerator.class.getResourceAsStream("/UpdateClass.template.java"))); Configuration cfg = new Configuration(); StringTemplateLoader loader = new StringTemplateLoader(); loader.putTemplate("template", template); cfg.setTemplateLoader(loader);/*from www . j a va 2 s . c om*/ cfg.setObjectWrapper(new DefaultObjectWrapper()); Template temp = cfg.getTemplate("template"); FileWriter fw = new FileWriter(outJavaFile); BufferedWriter bw = new BufferedWriter(fw); try { temp.process(this.buildTemplateModel(outJavaPackage), bw); } catch (TemplateException e) { throw new Error(e); } bw.close(); fw.close(); }
From source file:spoon.support.compiler.jdt.FileCompiler.java
/** * returns the compilation units corresponding to the types in the factory. *//*from w ww. j a v a2 s .c om*/ @Override public CompilationUnit[] getCompilationUnits() { List<SpoonFile> files = new ArrayList<>(); files.addAll(jdtCompiler.sources.getAllJavaFiles()); files.addAll(jdtCompiler.templates.getAllJavaFiles()); List<CompilationUnit> culist = new ArrayList<>(); for (SpoonFile f : files) { if (filesToBeIgnored.contains(f.getPath())) { continue; } try { String fName = ""; if (f.isActualFile()) { fName = f.getPath(); } else { fName = f.getName(); } culist.add(new CompilationUnit(IOUtils.toCharArray(f.getContent()), fName, null)); } catch (Exception e) { throw new SpoonException(e); } } return culist.toArray(new CompilationUnit[0]); }
From source file:tokyo.northside.omegat.markdown.OmegatMarkdownFilter.java
/** * Process Markdown file from reader.//from ww w . j a va2 s . co m * * @param reader reader specified to source markdown file. * @throws IOException throws when I/O error hapened. */ void process(final BufferedReader reader) throws IOException, TranslationException { process(IOUtils.toCharArray(reader)); }