title: Load a lot of properties file from a single text file and insert into LinkedHashMap
body: <p>I have a file which contains lots of properties file line by line may be around 1000 and each properties file will be having around 5000 key-value pair. For eg:- Sample Example(abc.txt)-</p>
  
  <pre><code>abc1.properties
  abc2.properties
  abc3.properties
  abc4.properties
  abc5.properties
  </code></pre>
  
  <p>So I am opening this file and as it reads each line I am loading the properties file in loadProperties method. And storing key-value pair from that property in LinkedHashMap.</p>
  
  <pre><code>public class Project {
      public static HashMap&lt;String, String&gt; hashMap;
  
      public static void main(String[] args) {
          BufferedReader br = null;
          hashMap = new LinkedHashMap&lt;String, String&gt;();
          try {
              br = new BufferedReader(new FileReader("C:\\apps\\apache\\tomcat7\\webapps\\examples\\WEB-INF\\classes\\abc.txt"));
              String line = null;
              while ((line = br.readLine()) != null) {
                  loadProperties(line);//loads abc1.properties first time
              }
          } catch (FileNotFoundException e1) {
              e1.printStackTrace();
          }
          catch (IOException e) {
              e.printStackTrace();
          } finally {
              try {
                  br.close();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      }
  //I am loading each property file in this method. And checking whether the key 
  already exists in the hashMap if it exists in the hashMap then concatenate the
  new key value  with the previous key value. And keep on doing everytime you 
  find key exists.
  
      private static void loadProperties(String line) {
          Properties prop = new Properties();
          InputStream in = Project.class.getResourceAsStream(line);
          String value = null;
          try {
              prop.load(in);
              for(Object str: prop.keySet()) {
                  if(hashMap.containsKey(str.toString())) {
                      StringBuilder sb = new StringBuilder().append(hashMap.get(str)).append("-").append(prop.getProperty((String) str));
                      hashMap.put(str.toString(), sb.toString());
                  } else {
                      value = prop.getProperty((String) str);
                      hashMap.put(str.toString(), value);
                      System.out.println(str+" - "+value);
                  }
              }
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } finally {
              try {
                  in.close();
              } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          }
  
  
      }
  
  }
  </code></pre>
  
  <p>So My Question is as I am having more than 1000 properties file and each properties file is having more than 5000 key-value pair. And most of the property file have the same key but with different values so I have to concatenate the value with the previous value if the key is same. So is there any limitation on the size with the LinkedHashMap as the property file keep on increasing and also the key-value pair in properties file. So this code is optimized enough to handle this kind of problem?</p>