Read through the `source` line by line and populate `map` with the data returned from the `parser`

@param source The ByteSource to read lines from
@param map    The map to populate

@return number of lines read and entries parsed

@throws IOException
962096
public PopulateResult populate(final ByteSource source, final Map<K, V> map) throws IOException
  {
    return source.asCharSource(StandardCharsets.UTF_8).readLines(
        new LineProcessor<PopulateResult>()
        {
          private int lines = 0;
          private int entries = 0;

          @Override
          public boolean processLine(String line)
          {
            if (lines == Integer.MAX_VALUE) {
              throw new ISE("Cannot read more than %,d lines", Integer.MAX_VALUE);
            }
            final Map<K, V> kvMap = parser.parseToMap(line);
            map.putAll(kvMap);
            lines++;
            entries += kvMap.size();
            return true;
          }

          @Override
          public PopulateResult getResult()
          {
            return new PopulateResult(lines, entries);
          }
        }
    );
  }
985732
public static Map<String, Object> read(StreamingInput input)
		throws IOException
	{
		Token next = input.peek();
		if(next == null) return Collections.emptyMap();

		switch(next)
		{
			case LIST_START:
			case LIST_END:
			case OBJECT_END:
			case VALUE:
			case NULL:
				throw new SerializationException("Error in configuration file, should be in in key, value format");
		}

		return readMap(input);
	}
992915
public void serialize(Map<String, T> map, OutputStream os) throws IOException {
        JsonGenerator jsonGenerator = LoganSquare.JSON_FACTORY.createGenerator(os);
        serialize(map, jsonGenerator);
        jsonGenerator.close();
    }
217090
@SneakyThrows
   public static String dumps(@NonNull Map<String, ?> map) {
      Resource strResource = new StringResource();
      try (JsonWriter writer = new JsonWriter(strResource)) {
         writer.beginDocument();
         for (Map.Entry<String, ?> entry : map.entrySet()) {
            writer.property(entry.getKey(), entry.getValue());
         }
         writer.endDocument();
      }
      return strResource.readToString().trim();
   }
1341775
public static <K> Integer getCount(Map<K, Integer> map, K k)
    {
        Integer count = map.get(k);
        if (count == null)
        {
            count = 0;
            map.put(k, count);
        }
        return count;
    }
678726
public static void decode(final Map<String, String> map, final String data) {
        //String[] keyValues = StringUtil.split(data, '&');
        StringUtil.split(data, '&',  keyValue -> {
            final int indexOfSeperator = keyValue.indexOf('=');
            
            if (indexOfSeperator > -1) {
                if (indexOfSeperator == keyValue.length() - 1) { // The '=' is at the end of the string - this counts as an unsigned value
                    map.put(URLCodec.decode(keyValue.substring(0, indexOfSeperator), StandardCharsets.UTF_8), "");
                } else {  
                    final String first  = keyValue.substring(0, indexOfSeperator),
                                 second = keyValue.substring(indexOfSeperator + 1);
                 
                    map.put(URLCodec.decode(first, StandardCharsets.UTF_8), URLCodec.decode(second, StandardCharsets.UTF_8));
                }
            }
        });
    }
546233
public static void readAbbrList(String dataFile, Map map) throws IOException {
		BufferedReader fin = new BufferedReader(new FileReader(dataFile));
		
		String line;
		while ((line = fin.readLine()) != null) {
		    StringTokenizer strTok = new StringTokenizer(line, " \t\r\n");
		    
		    if (strTok.countTokens() <= 0) {
			continue;
		    } 
		    
		    String token = strTok.nextToken();
		    
		    map.put(token.toLowerCase(), token.toLowerCase());
		}
    }
717093
public Map<Object, String> read(Reader reader) throws IOException {
        Map<Object, String> cvs = new HashMap<>();
        try (CSVReader r = new CSVReader(reader, '\t')) {
            String[] cols;
            int i = 1;
            while ((cols = r.readNext()) != null) {
                switch (cols.length) {
                    case 0:
                        break;
                    case 1:
                        String col0 = cols[0];
                        if (col0.length() > 1) {
                            cvs.put(col0, "");
                        }
                        break;
                    case 2:
                        cvs.put(cols[1], cols[0]);
                        break;
                    default:
                        throw new IOException("Invalid mapping in line " + i + ": mapping has length " + cols.length);
                }
                i++;
            }
        }
        return cvs;
    }
889759
public static <K, E> List<E> getAndPutListIfAbsent(final Map<K, List<E>> map, final K key) {
        List<E> v = map.get(key);

        if (v == null) {
            v = new ArrayList<>();
            v = map.put(key, v);
        }

        return v;
    }
766858
public void read(@WillClose InputStream inputStream) throws IOException {
        BufferedReader reader = new BufferedReader(Util.getReader(inputStream));

        int lineNumber = 0;
        try {
            String line;
            int lparen;
            String version;

            while ((line = reader.readLine()) != null) {
                ++lineNumber;

                if (lineNumber == 1) {
                    if (DEBUG) {
                        System.out.println("First line: " + line);
                    }
                    // Try to parse the version number string from the first
                    // line.
                    // null means that the line does not appear to be a version
                    // number.
                    version = parseVersionNumber(line);
                    if (version != null) {
                        // Check to see if version is supported.
                        // Only 1.0 supported for now.
                        if (!"1.0".equals(version)) {
                            throw new IOException("Unsupported sourceInfo version " + version);
                        }

                        // Version looks good. Skip to next line of file.
                        continue;
                    }
                }

                StringTokenizer tokenizer = new StringTokenizer(line, ",");

                String className = tokenizer.nextToken();
                String next = tokenizer.nextToken();
                if (DIGITS.matcher(next).matches()) {
                    // Line number for class
                    SourceLineRange range = createRange(next, tokenizer.nextToken());
                    classLineMap.put(className, range);
                    if (DEBUG) {
                        System.out.println("class:" + className + "," + range);
                    }
                } else if ((lparen = next.indexOf('(')) >= 0) {
                    // Line number for method
                    String methodName = next.substring(0, lparen);
                    String methodSignature = next.substring(lparen);

                    if ("init^".equals(methodName)) {
                        methodName = "<init>";
                    } else if ("clinit^".equals(methodName)) {
                        methodName = "<clinit>";
                    }

                    SourceLineRange range = createRange(tokenizer.nextToken(), tokenizer.nextToken());
                    methodLineMap.put(new MethodDescriptor(className, methodName, methodSignature), range);
                    if (DEBUG) {
                        System.out.println("method:" + methodName + methodSignature + "," + range);
                    }
                } else {
                    // Line number for field
                    String fieldName = next;
                    SourceLineRange range = createRange(tokenizer.nextToken(), tokenizer.nextToken());
                    fieldLineMap.put(new FieldDescriptor(className, fieldName), range);
                    if (DEBUG) {
                        System.out.println("field:" + className + "," + fieldName + "," + range);
                    }
                }

                // Note: we could complain if there are more tokens,
                // but instead we'll just ignore them.
            }
        } catch (NoSuchElementException e) {
            IOException ioe = new IOException("Invalid syntax in source info file at line " + lineNumber);
            ioe.initCause(e);
            throw ioe;
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                // ignore
            }
        }
    }
1307932
private void readMap(final Element map, final Map<String, KeyDef> keyDefs) {
        readKeyDefinition(map, keyDefs);
        for (final Element elem: getChildElements(map)) {
            if (!(SUBMAP.matches(elem) || elem.getAttributeNode(ATTRIBUTE_NAME_KEYSCOPE) != null)) {
                readMap(elem, keyDefs);
            }
        }
    }
825726
static Map<String, ?> buildSourceByJsonMapper(Object sourceObject) {
        try {
            return JsonMapper.convertValue(sourceObject, MAP_TYPE_REFERENCE);
        } catch (Exception e) {
            return JMExceptionManager.handleExceptionAndThrowRuntimeEx(log, e,
                    "buildSourceByJsonMapper", sourceObject);
        }
    }
1286612
public String serialize(Map<String, T> map) throws IOException {
        StringWriter sw = new StringWriter();
        JsonGenerator jsonGenerator = LoganSquare.JSON_FACTORY.createGenerator(sw);
        serialize(map, jsonGenerator);
        jsonGenerator.close();
        return sw.toString();
    }
412012
public static void jsonMap(JsonWriter writer, Map<String, Object> map) throws IOException {
        if (map != null) {
            writer.beginObject();
            jsonMapEntries(writer, map);
            writer.endObject();
        }
    }
1153363
public static void copy(InputStream source, OutputStream destination) throws IOException
    {
        Check.notNull(source);
        Check.notNull(destination);

        final byte[] buffer = new byte[BUFFER_COPY];
        while (true)
        {
            final int read = source.read(buffer);
            if (read == -1)
            {
                break;
            }
            destination.write(buffer, 0, read);
        }
    }
392105
private Object invokeMapper(File source) throws IOException {
        Object[] results;
        String name;
        Reader src;

        name = source.getPath();
        mork.output.verbose("mapping " + name);
        results = run(name);
        mork.output.verbose("finished mapping " + name);
        if (results == null) {
            return null;
        } else {
            return results[0];
        }
    }
755176
private <D,S> JMapper<D,S> getJMapper(HashMap<String,JMapper> map,Object source){
		Class<?> sourceClass = source instanceof Class?((Class<?>)source):source.getClass();
		JMapper<D,S> jMapper = map.get(sourceClass.getName());
		if(jMapper == null) Error.classNotMapped(source, configuredClass);
		return jMapper;
	}