public static final String readText(InputStream in) throws IOException { return readText(in, null); } public static final List<String> readLines(String s) throws IOException {
public static final String readText(InputStream in) throws IOException { return readText(in, null); } public static final List<String> readLines(String s) throws IOException {
@Override public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { return ReadText.readText(url); }
@Override public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { return ReadText.readText(url); }
boolean load() { if (!persistentFile.exists()) return false; sourceTextArea.setText(ReadText.readText(persistentFile)); return true; } void save() {
public String generateMavenProjectModel(String groupId, String artifactId, String version) throws IOException { String res = "com/ochafik/lang/jnaerator/" + name() + "-pom.xml"; String pom = ReadText.readText(getClass().getClassLoader().getResource(res)); if (pom == null) { throw new FileNotFoundException(res); } pom = pom. replaceAll("%groupId%", groupId). replaceAll("%artifactId%", artifactId). replaceAll("%version%", version); return pom; } }
public String generateMavenProjectModel(String groupId, String artifactId, String version) throws IOException { String res = "com/ochafik/lang/jnaerator/" + name() + "-pom.xml"; String pom = ReadText.readText(getClass().getClassLoader().getResource(res)); if (pom == null) { throw new FileNotFoundException(res); } pom = pom. replaceAll("%groupId%", groupId). replaceAll("%artifactId%", artifactId). replaceAll("%version%", version); return pom; } }
public static final String readText(URL u) throws IOException { if (u == null) return null; String encoding = null; URLConnection con = u.openConnection(); // if (con instanceof HttpsURLConnection) { // ((HttpsURLConnection)con).setHostnameVerifier(new HostnameVerifier() { // public boolean verify(String hostname, SSLSession session) { // return true; // } // }); // } if (con instanceof HttpURLConnection) { String contentType = con.getContentType(); encoding = RegexUtils.findFirst(contentType, charsetPattern, 1); } InputStream in = con.getInputStream(); String text = readText(in, encoding); in.close(); return text; } static Pattern[] embeddedCharsetPatterns = new Pattern[] {
public static final String readText(URL u) throws IOException { if (u == null) return null; String encoding = null; URLConnection con = u.openConnection(); // if (con instanceof HttpsURLConnection) { // ((HttpsURLConnection)con).setHostnameVerifier(new HostnameVerifier() { // public boolean verify(String hostname, SSLSession session) { // return true; // } // }); // } if (con instanceof HttpURLConnection) { String contentType = con.getContentType(); encoding = RegexUtils.findFirst(contentType, charsetPattern, 1); } InputStream in = con.getInputStream(); String text = readText(in, encoding); in.close(); return text; } static Pattern[] embeddedCharsetPatterns = new Pattern[] {
@SuppressWarnings("deprecation") public static void main(String args[]) { JFrame f=new JFrame("Test"); String text=args.length==0 ? "" : ReadText.readText(new File(args[0])); JEditTextArea ta=new JEditTextArea(); ta.setText(text); f.getContentPane().add("Center",new JScrollPane(ta)); f.pack(); f.show(); } }
public void parse() throws Exception { if (idToProject == null) { idToProject = new LinkedHashMap<String, Project>(); String solutionContent = ReadText.readText(solutionFile); File solutionPath = solutionFile.getParentFile(); for (Matcher solutionIdMatcher = solutionIdPattern.matcher(solutionContent.replace('\n', ' ')); solutionIdMatcher.find();) { Project p = new Project(this, relFile(solutionPath, solutionIdMatcher.group(2)), solutionIdMatcher.group(1), solutionIdMatcher.group(3)); for (Matcher depM = projectDependencyPattern.matcher(solutionIdMatcher.group(4)); depM.find();) { p.depsIds.add(depM.group(1)); } idToProject.put(p.id, p); } for (Matcher m = projectConfigsForSolutionConfigPattern.matcher(solutionContent); m.find();) { String id = m.group(1), slnConfigName = m.group(2), projConfigName = m.group(3); Project p = idToProject.get(id); if (p == null) { continue; } p.activeConfigurationNameBySolutionConfigurationName.put(slnConfigName, projConfigName); } } }
private void outputScalaRuntime(List<String> availableLibs) throws IOException { PrintWriter out = openFile(new File(result.config.scalaOut, SCALA_JNAERATOR_RT_CLASS_NAME + ".scala")); out.println(ReadText.readText(getScalaPartResource(SCALA_JNA_RT_CLASS_NAME))); boolean objc = result.hasObjectiveC(); if (objc) { out.println(ReadText.readText(getScalaPartResource(SCALA_ROCOCOA_RT_CLASS_NAME))); } out.print("trait " + SCALA_JNAERATOR_RT_CLASS_NAME + " extends " + SCALA_JNA_RT_CLASS_NAME); if (objc) { out.print(" with " + SCALA_ROCOCOA_RT_CLASS_NAME); } //out.println(" {"); out.close(); }
private void outputScalaRuntime(List<String> availableLibs) throws IOException { PrintWriter out = openFile(new File(result.config.scalaOut, SCALA_JNAERATOR_RT_CLASS_NAME + ".scala")); out.println(ReadText.readText(getScalaPartResource(SCALA_JNA_RT_CLASS_NAME))); boolean objc = result.hasObjectiveC(); if (objc) { out.println(ReadText.readText(getScalaPartResource(SCALA_ROCOCOA_RT_CLASS_NAME))); } out.print("trait " + SCALA_JNAERATOR_RT_CLASS_NAME + " extends " + SCALA_JNA_RT_CLASS_NAME); if (objc) { out.print(" with " + SCALA_ROCOCOA_RT_CLASS_NAME); } //out.println(" {"); out.close(); }
private void doShowExample(boolean generate) { try { sourceArea.setText(ReadText.readText(getClass().getClassLoader().getResourceAsStream( "com/ochafik/lang/jnaerator/examples/example.h"))); sourceArea.scrollTo(0, 0); if (generate) { generate(); } } catch (Exception e1) { e1.printStackTrace(); } }
private void doShowExample(boolean generate) { try { sourceArea.setText(ReadText.readText(getClass().getClassLoader().getResourceAsStream( "com/ochafik/lang/jnaerator/examples/example.h"))); sourceArea.scrollTo(0, 0); if (generate) { generate(); } } catch (Exception e1) { e1.printStackTrace(); } }
public void parse() throws Exception { if (idToProject == null) { idToProject = new LinkedHashMap<String, Project>(); String solutionContent = ReadText.readText(solutionFile); File solutionPath = solutionFile.getParentFile(); for (Matcher solutionIdMatcher = solutionIdPattern.matcher(solutionContent.replace('\n', ' ')); solutionIdMatcher.find();) { Project p = new Project(this, relFile(solutionPath, solutionIdMatcher.group(2)), solutionIdMatcher.group(1), solutionIdMatcher.group(3)); for (Matcher depM = projectDependencyPattern.matcher(solutionIdMatcher.group(4)); depM.find();) { p.depsIds.add(depM.group(1)); } idToProject.put(p.id, p); } for (Matcher m = projectConfigsForSolutionConfigPattern.matcher(solutionContent); m.find();) { String id = m.group(1), slnConfigName = m.group(2), projConfigName = m.group(3); Project p = idToProject.get(id); if (p == null) { continue; } p.activeConfigurationNameBySolutionConfigurationName.put(slnConfigName, projConfigName); } } }
private List<String> parsedArgsInclude(ParsedArg a) throws IOException { final File argsFile = a.getFileParam(0); String argsFileContent = ReadText.readText(argsFile); Adapter<String[], String> argVariableReplacer = new Adapter<String[], String>() { @Override
private List<String> parsedArgsInclude(ParsedArg a) throws IOException { final File argsFile = a.getFileParam(0); String argsFileContent = ReadText.readText(argsFile); Adapter<String[], String> argVariableReplacer = new Adapter<String[], String>() { @Override
String sourceContent = ReadText.readText(new CppReader(preProcessor)); preProcessor.close();
String sourceContent = ReadText.readText(new CppReader(preProcessor)); preProcessor.close();