List of usage examples for java.io StringReader ready
public boolean ready() throws IOException
From source file:Main.java
public static void main(String[] argv) throws IOException { StringReader stringReader = new StringReader("java2s.com"); System.out.println(stringReader.ready()); char[] charArray = new char[10]; stringReader.read(charArray);// w w w .java 2 s.c o m System.out.println(Arrays.toString(charArray)); stringReader.close(); }
From source file:fi.uta.infim.usaproxylogparser.UsaProxyHTTPTrafficLogParser.java
/** * Converts a UsaProxy DOM path to an XPath expression * @param usaProxyPath usaproxy dom path * @return XPath expression as string/*from w w w . j a va 2s .c o m*/ * @throws IOException * @throws XPathExpressionException */ static String usaProxyDOMPathToXPath(String usaProxyPath) throws IOException, XPathExpressionException { String path = ""; StringReader reader = new StringReader(usaProxyPath); while (reader.ready()) { int depth = 0; // Index of the child element int currentChar; String prefix = "0"; while (Character.isDigit(currentChar = reader.read())) { prefix += String.valueOf((char) currentChar); } if (currentChar == -1) break; depth += Integer.parseInt(prefix) * 26; depth += currentChar - ((int) 'a') + 1; // assuming ascii charset path += "/*[" + String.valueOf(depth) + "]"; } return path; }
From source file:it.geosolutions.geoserver.jms.impl.handlers.DocumentFile.java
/** * /*from www . j av a 2 s. c om*/ * @param file * @param xml * @throws JDOMException * @throws IOException */ protected static void writer(File file, String xml) throws JDOMException, IOException { FileWriter writer = null; StringReader reader = null; try { writer = new FileWriter(file); reader = new StringReader(xml); char[] cbuf = new char[2048]; int size = 0; while (reader.ready() && (size = reader.read(cbuf)) != -1) { writer.write(cbuf, 0, size); } } finally { writer.flush(); IOUtils.closeQuietly(writer); IOUtils.closeQuietly(reader); } }