Using Properties class:
#store the contacts
#Sun Apr 29 20:22:15 IST 2018
delhi=ritesh
japan=chet
chennai=ishaan
bangalore=raju
- import java.io.File;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.util.Properties;
- public class WritePropertiesFiles {
- public static void main(String[] args) throws IOException {
- Properties prop = new Properties();
- prop.setProperty("bangalore", "raju");
- prop.setProperty("delhi", "ritesh");
- prop.setProperty("chennai", "ishaan");
- prop.setProperty("japan", "chet");
- File file = new File("D:\\contacts.properties");
- FileOutputStream fileStream = new FileOutputStream(file);
- prop.store(fileStream, "store the contacts");
- fileStream.close();
- }
- }
#store the contacts
#Sun Apr 29 20:22:15 IST 2018
delhi=ritesh
japan=chet
chennai=ishaan
bangalore=raju
No comments:
Post a Comment