@Test public void testBuildReplacementReaderWithReplacements() { String input = "'Replace all' tick's i'n thi's text'"; String expected = "FReplace allF tickFs iFn thiFs textF"; assertEquals(expected, readToEnd(CharacterReplacementStreamBuilder.buildReplacementReader(new StringReader( input), '\'', "F"))); }
public static Reader buildReplacementReader(final Reader inReader, final char inReplaceFrom, final String inReplaceTo) { int c; StringWriter sw = new StringWriter(); try { while ((c = inReader.read()) != -1) { if (c == inReplaceFrom) { sw.write(inReplaceTo); } else { sw.write(c); } } } catch (IOException e) { throw new RuntimeException("Error while parsing content: " + e.getMessage(), e); } return new StringReader(sw.toString()); }
CharacterReplacementStreamBuilder { public static Reader buildReplacementReader(final Reader inReader, final char inReplaceFrom, final String inReplaceTo) { int c; StringWriter sw = new StringWriter(); try { while ((c = inReader.read()) != -1) { if (c == inReplaceFrom) { sw.write(inReplaceTo); } else { sw.write(c); } } } catch (IOException e) { throw new RuntimeException("Error while parsing content: " + e.getMessage(), e); } return new StringReader(sw.toString()); } }
CharacterReplacementStreamBuilder { public static Reader buildReplacementReader(final Reader inReader, final char inReplaceFrom, final String inReplaceTo) { int c; StringWriter sw = new StringWriter(); try { while ((c = inReader.read()) != -1) { if (c == inReplaceFrom) { sw.write(inReplaceTo); } else { sw.write(c); } } } catch (IOException e) { throw new RuntimeException("Error while parsing content: " + e.getMessage(), e); } return new StringReader(sw.toString()); } private  CharacterReplacementStreamBuilder(); }
CharacterReplacementStreamBuilder { public static Reader buildReplacementReader(final Reader inReader, final char inReplaceFrom, final String inReplaceTo) { int c; StringWriter sw = new StringWriter(); try { while ((c = inReader.read()) != -1) { if (c == inReplaceFrom) { sw.write(inReplaceTo); } else { sw.write(c); } } } catch (IOException e) { throw new RuntimeException("Error while parsing content: " + e.getMessage(), e); } return new StringReader(sw.toString()); } private  CharacterReplacementStreamBuilder(); static Reader buildReplacementReader(final Reader inReader, final char inReplaceFrom,
            final String inReplaceTo); }
CharacterReplacementStreamBuilder { public static Reader buildReplacementReader(final Reader inReader, final char inReplaceFrom, final String inReplaceTo) { int c; StringWriter sw = new StringWriter(); try { while ((c = inReader.read()) != -1) { if (c == inReplaceFrom) { sw.write(inReplaceTo); } else { sw.write(c); } } } catch (IOException e) { throw new RuntimeException("Error while parsing content: " + e.getMessage(), e); } return new StringReader(sw.toString()); } private  CharacterReplacementStreamBuilder(); static Reader buildReplacementReader(final Reader inReader, final char inReplaceFrom,
            final String inReplaceTo);  }