PropertiesTest.java


Dosyayı İndir
package com.godoro.samples.util;
import java.util.*;
import java.io.*;

public class PropertiesTest {

  public static void createTest(String path)
    throws IOException
  { 
    Properties properties=new Properties();
    properties.setProperty("font","Arial");
    properties.setProperty("background","red");
    properties.setProperty("logo","/img/mylogo.gif");    
    FileOutputStream fos=new FileOutputStream(path);
    properties.store(fos,"");            
    fos.close();    
  }
  public static void loadTest(String path)
    throws IOException
  { 
    Properties properties=new Properties();    
    FileInputStream fis=new FileInputStream(path);
    properties.load(fis);   
    fis.close();
    String font=properties.getProperty("font");
    System.out.println("font : "+font);
  }
  public static void changeTest(String path)
    throws IOException
  { 
    Properties properties=new Properties();    
    FileInputStream fis=new FileInputStream(path);
    properties.load(fis);   
    fis.close();
    properties.setProperty("font","Times New Roman");
    properties.setProperty("width","400");
    properties.setProperty("height","600");
    FileOutputStream fos=new FileOutputStream(path);
    properties.store(fos,"");            
    fos.close();        
  }
  
  public static void main(String[] args)
    throws IOException
  { 
    String path="C:\\Godoro\\Projects\\Java\\Education\\JavaBook\\test\\test.properties";    
    //createTest(path);
    loadTest(path);
    //changeTest(path);
    
  }  
  
}

				
Dosyayı İndir

Bu Sayfayı Paylaş:




Bu Sayfayı Paylaş:

İletişim Bilgileri

Takip Et

Her Hakkı Saklıdır. Bu sitede yayınlanan tüm bilgi ve fikirlerin kullanımından fibiler.com sorumlu değildir. Bu sitede üretilmiş , derlenmiş içerikleri, fibiler.com'u kaynak göstermek koşuluyla kendi sitenizde kullanılabilirsiniz. Ancak telif hakkı olan içeriklerin hakları sahiplerine aittir