Advertisement
iPeer

Untitled

Oct 6th, 2011
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. /*
  2. * INI.Write(new File(FILE),key,data);
  3. * INI.Read(new File(FILE),key);
  4. */
  5.  
  6. import java.io.*;
  7. import java.util.*;
  8.  
  9. public class INI {
  10.  
  11.     public static void Write(File f, String p1, String p2) {
  12.         System.out.println(f.toString() +"\\"+p1+"\\"+p2);
  13.         Properties r = new Properties();
  14.         try {
  15.             r.load(new FileInputStream(f));
  16.             r.setProperty(p1,p2);
  17.             r.list(System.out);
  18.             r.store(new FileOutputStream(f), null);
  19.         }
  20.         catch (Exception e) {
  21.             System.out.println("Unable to write to INI! "+e);
  22.         }
  23.     }
  24.  
  25.     public static String read (File f, String p1) {
  26.         String o = "";
  27.         System.out.println(f.getAbsolutePath());
  28.         Properties r = new Properties();
  29.         try {
  30.             r.load(new FileInputStream(f));
  31.             o = r.getProperty(p1);
  32.         }
  33.         catch (Exception e) {
  34.             System.out.println("Unable to read INI! "+e);
  35.         }
  36.         return o;
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement