Examples of LineIterator


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

        return this.convertLinesToStream(message, in, path);
    }

    protected String convertLinesToString(NormalizedMessage message,
                                          InputStream in, String path) throws IOException {
        LineIterator lines = IOUtils.lineIterator(in, this.encoding);

        StringBuffer aBuffer = new StringBuffer(1024);

        if (this.xmlDeclaration) {
            aBuffer.append(XMLDECLARATION_LINE);
        }

        aBuffer.append(XML_OPEN + this.docElementname);

        if (this.docElementNamespace != null) {
            aBuffer.append("xmlns=\"");
            aBuffer.append(this.docElementNamespace);
            aBuffer.append("\"");
        }

        aBuffer.append(" name=\"");
        aBuffer.append(new File(path).getName());
        aBuffer.append("\"");

        aBuffer.append(" location=\"");
        aBuffer.append(path);
        aBuffer.append(XML_CLOSE_ATTR_NEWLINE);

        this.processHeaderLines(aBuffer, lines);

        int lineNumber = 1;
        while (lines.hasNext()) {
            String lineText = lines.nextLine();
            aBuffer.append(XML_OPEN + this.lineElementname);

            if (this.insertLineNumbers || this.insertRawData) {
                if (this.insertLineNumbers) {
                    aBuffer.append(" number=\"");
View Full Code Here

Examples of org.apache.commons.io.LineIterator

        ExternalSorter<String> sorter = new ExternalSorter<String>(new StringSerializer(),
                                                                   internalSortSize,
                                                                   numThreads);
        @SuppressWarnings("unchecked")
        Iterator<String> it = new LineIterator(new BufferedReader(new FileReader(input),
                                                                  10 * 1024 * 1024));

        String seperator = Utils.NEWLINE;
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out),
                                                   10 * 1024 * 1024);
 
View Full Code Here

Examples of org.apache.commons.io.LineIterator

                                thread.setDaemon(true);
                                return thread;
                            }
                        });

        LineIterator iterator = FileUtils.lineIterator(fs.getGcCandidates(), Charsets.UTF_8.name());
        List<String> ids = Lists.newArrayList();
        int count = 0;
        while (iterator.hasNext()) {
            ids.add(iterator.next());

            if (ids.size() > getBatchCount()) {
                count += ids.size();
                executorService.execute(new Sweeper(ids, exceptionQueue));
                ids = Lists.newArrayList();
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 {
                LineIterator it = IOUtils.lineIterator(instream,
                        EntityUtils.getContentCharSet(requestEntity));
                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

    public static List<String> readLinesFromFile(
            String filename, String encoding
    ) throws IOException {
        List<String> lines = new ArrayList<String>();
        File file = new File(filename);
        LineIterator it = FileUtils.lineIterator(file, encoding);
        try {
            while (it.hasNext()) {
                String line = it.nextLine();
                lines.add(line);
            }
        } finally {
            it.close();
        }
        return lines;
    }
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.