Java Properties Load from File load(InputStream stream)

Here you can find the source of load(InputStream stream)

Description

load

License

Apache License

Declaration

public static void load(InputStream stream) 

Method Source Code


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

import java.io.*;
import java.util.*;

public class Main {
    private static final Properties PROPERTIES = new Properties();

    public static void load(InputStream stream) {
        load(stream, false);/*from   w  w  w.j  a v a 2  s  .c o  m*/
    }

    private static void load(InputStream stream, boolean ignoreError) {
        PROPERTIES.clear();

        try {
            if (stream != null) {
                PROPERTIES.load(stream);
                stream.close();

                if (PROPERTIES.size() == 0 && !ignoreError) {
                    throw new RuntimeException("Empty [config.properties]!");
                }
            } else if (!ignoreError) {
                throw new RuntimeException("Config file not found");
            }
        } catch (Exception e) {
            throw new RuntimeException("Can't load [config.properties]!", e);
        }
    }
}

Related

  1. load(final String folder, final String fileName)
  2. load(InputStream in)
  3. load(InputStream input)
  4. load(InputStream inputStream)
  5. load(InputStream is)
  6. load(Map map, String fileName)
  7. load(Properties properties, String fileName)
  8. load(Properties props, Collection filters, File basedir)
  9. load(Properties props, File f)