Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {

    public static void main(String[] args) throws Exception {
        Properties prop = new Properties();
        String s = "Chapter Count=200";
        String s2 = "Tutorial Count=15";

        // create a new input and output stream
        FileOutputStream fos = new FileOutputStream("properties.txt");
        FileInputStream fis = new FileInputStream("properties.txt");

        // write the first property in the output stream file
        fos.write(s.getBytes());

        // change the line between the two properties
        fos.write("\n".getBytes());

        // write next property
        fos.write(s2.getBytes());

        // load from input stream
        prop.load(fis);

        // print the properties list from System.out
        prop.list(System.out);

    }
}