Java Iterator createMap(Iterator iter)

Here you can find the source of createMap(Iterator iter)

Description

create Map

License

Apache License

Declaration

private static Map<String, String> createMap(Iterator<String> iter) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.HashMap;
import java.util.Iterator;

import java.util.Map;

public class Main {
    private static Map<String, String> createMap(Iterator<String> iter) {

        boolean finished = false;
        Map<String, String> m = new HashMap<String, String>();
        while (iter.hasNext() && !finished) {
            String row = iter.next();
            if (row.startsWith("~")) {
                finished = true;//w w w.j  ava2s. c om
            } else {
                String[] tokens = row.split("\\^");
                m.put(tokens[1].trim(), tokens[0].substring(1).trim());
            }
        }
        return m;
    }
}

Related

  1. copyIterator(Iterable iterable)
  2. copyIterator(Iterator iter)
  3. copyOf(Iterator elements)
  4. count(Iterator thingsToCount)
  5. countIterator(Iterator it)
  6. createPathIterator(String path)
  7. createSkipIterator(Iterable source, int count)
  8. dump(Iterator it)
  9. endOfData(Iterator inputIter, Iterator resultIter)