Read Properties File - Android java.util

Android examples for java.util:Properties

Description

Read Properties File

Demo Code


import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;

public class Main {
  public static final String filePath = "cookie.prop";

  public static Properties get() {
    FileInputStream fis = null;/*ww w .  j  av  a  2 s . c  o m*/
    Properties props = new Properties();
    try {

      File Conf = new File(filePath);
      if (!Conf.exists()) {
        Conf.createNewFile();
      }
      fis = new FileInputStream(Conf);
      props.load(fis);
    } catch (Exception e) {
    } finally {
      try {
        fis.close();
      } catch (Exception e) {
      }
    }
    return props;
  }
}

Related Tutorials