Examples of LineIterator


Examples of org.apache.commons.io.LineIterator

                final ContentType contentType = ContentType.getOrDefault(requestEntity);
                Charset charset = contentType.getCharset();
                if (charset == null) {
                    charset = Consts.ISO_8859_1;
                }
                final LineIterator it = IOUtils.lineIterator(instream, charset.name());
                int count = 0;
                while (it.hasNext()) {
                    final String line = it.next();
                    final int i = count % TEXT.length;
                    final String expected = TEXT[i];
                    if (!line.equals(expected)) {
                        ok = false;
                        break;
View Full Code Here

Examples of org.apache.commons.io.LineIterator

        Integer status = future.get();
        Assert.assertNotNull(status);
        Assert.assertEquals(HttpStatus.SC_OK, status.intValue());
        InputStream instream = new FileInputStream(this.tmpfile);
        try {
            LineIterator it = IOUtils.lineIterator(instream, ASCII.name());
            int count = 0;
            while (it.hasNext()) {
                String line = it.next();
                int i = count % TEXT.length;
                String expected = TEXT[i];
                Assert.assertEquals(expected, line);
                count++;
            }
View Full Code Here

Examples of org.apache.commons.io.LineIterator

        Integer status = future.get();
        Assert.assertNotNull(status);
        Assert.assertEquals(HttpStatus.SC_OK, status.intValue());
        InputStream instream = new FileInputStream(this.tmpfile);
        try {
            LineIterator it = IOUtils.lineIterator(instream, ASCII.name());
            int count = 0;
            while (it.hasNext()) {
                String line = it.next();
                int i = count % TEXT.length;
                String expected = TEXT[i];
                Assert.assertEquals(expected, line);
                count++;
            }
View Full Code Here

Examples of org.apache.commons.io.LineIterator

            boolean ok = true;

            InputStream instream = requestEntity.getContent();
            try {
                ContentType contentType = ContentType.getOrDefault(requestEntity);
                LineIterator it = IOUtils.lineIterator(instream, contentType.getCharset());
                int count = 0;
                while (it.hasNext()) {
                    String line = it.next();
                    int i = count % TEXT.length;
                    String expected = TEXT[i];
                    if (!line.equals(expected)) {
                        ok = false;
                        break;
View Full Code Here

Examples of org.apache.commons.io.LineIterator

    URL resource = getClass().getResource( RESOURCE_NAME_DE_PLZ_TXT );
    if ( resource == null ) {
      throw new IOException( "Resource \"" + RESOURCE_NAME_DE_PLZ_TXT + "\" not found" );
    }

    LineIterator iterator = IOUtils.lineIterator( resource.openStream(), "UTF-8" );
    while ( iterator.hasNext() ) {
      String line = iterator.nextLine();
      String[] parts = line.split( "\t" );
      if ( parts.length < 2 ) {
        continue;
      }
View Full Code Here

Examples of org.apache.commons.io.LineIterator

    URL resource = getClass().getResource( RESOURCE_NAME_DE_PLZ_TXT );
    if ( resource == null ) {
      throw new IOException( "Resource \"" + RESOURCE_NAME_DE_PLZ_TXT + "\" not found" );
    }

    LineIterator iterator = IOUtils.lineIterator( resource.openStream(), "UTF-8" );
    while ( iterator.hasNext() ) {
      String line = iterator.nextLine();
      String[] parts = line.split( "\t" );
      if ( parts.length == 0 ) {
        continue;
      }
View Full Code Here

Examples of org.apache.commons.io.LineIterator

   */
  public static String asString(ClientResponse response) throws IOException {

    StringWriter out = new StringWriter();
    try {
      LineIterator itr = IOUtils.lineIterator(
          response.getEntityInputStream(), "UTF-8");
      while (itr.hasNext()) {
        String line = itr.next();
        out.write(line + (itr.hasNext() ? "\n" : ""));
      }
    } finally {
      closeQuietly(response.getEntityInputStream());
    }
    return out.toString();
View Full Code Here

Examples of org.apache.commons.io.LineIterator

        //UTF-8, but some configurations might want to use URLs as keys!
        Map<String,Object> configMap = new HashMap<String,Object>();
        try {
            InputStream in = openConfig(configFile);
            if(in != null){
                LineIterator lines = IOUtils.lineIterator(in, "UTF-8");
                while(lines.hasNext()){
                    String line = (String)lines.next();
                    if(!line.isEmpty()){
                        int indexOfEquals = line.indexOf('=');
                        String key = indexOfEquals > 0 ?
                                line.substring(0,indexOfEquals).trim():
                                    line.trim();
View Full Code Here

Examples of org.apache.commons.io.LineIterator

    }
   
    private List<String> getExampleBenchmarkPaths(HttpServletRequest request) throws IOException {
        // TODO how to enumerate bundle resources?
        final String list = getBenchmarkText("/LIST.txt");
        final LineIterator it = new LineIterator(new StringReader(list));
        final List<String> result = new LinkedList<String>();
        while(it.hasNext()) {
            result.add(getExampleBenchmarkPath(request, it.nextLine()));
        }
        return result;
    }
View Full Code Here

Examples of org.apache.commons.io.LineIterator

    public RequestExecutor assertContentRegexp(boolean expected, String... regexp) {
        assertNotNull(this.toString(), response);
        nextPattern:
        for (String expr : regexp) {
            final Pattern p = Pattern.compile(".*" + expr + ".*");
            final LineIterator it = new LineIterator(new StringReader(contentString));
            while (it.hasNext()) {
                final String line = it.nextLine();
                if (expected & p.matcher(line).matches()) {
                    continue nextPattern;
                }
                if(!expected & p.matcher(line).matches()) {
                    fail(this + ": match found for regexp '" + expr + "', content=\n" + contentString);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.