Java Properties load from file

Introduction

We can load text file with the following format to Properties:

prop1=line1\
line2\
line3

The code above added a slash \ to continue the value on the next line.

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

public class Main {
  public static void main(String args[]) throws Exception {
    Properties p = new Properties();
    p.load(new FileInputStream("Main.txt"));
    /* w  w  w  .  j  a v a2 s  .  c o  m*/
  }
}



PreviousNext

Related