1 10 11 package org.netbeans.modules.piagetproject.topcomponent; 12 import java.io.File ; 13 import java.io.FileInputStream ; 14 import java.io.FileNotFoundException ; 15 import java.io.IOException ; 16 import java.util.Enumeration ; 17 import java.util.Properties ; 18 import org.netbeans.modules.piagetproject.treestructure.SessionNode; 19 import org.netbeans.modules.piagetproject.property.Property; 20 21 25 public class SessionFileWrapper { 26 27 static File f; 28 static Properties p; 29 static SessionTopComponent tc; 30 private static String level, username; 31 32 33 public static String wrapFile(String filepath, String myUsername, String myLevel) { 34 username = myUsername; 35 level = myLevel; 36 f = new File (filepath); 37 38 FileInputStream in = null; 39 try{ 40 in = new FileInputStream (f); 41 }catch(FileNotFoundException e){ 42 e.printStackTrace(System.out); 43 } 44 45 Properties p = new Properties (); 46 try{ 47 p.load(in); 48 Enumeration en = p.keys(); 49 Property pd; 50 while(en.hasMoreElements()){ 51 String key = (String ) en.nextElement(); 52 Property.addProperty(key, p.getProperty(key)); 53 } 54 } catch(IOException e){ 55 e.printStackTrace(System.out); 56 } 57 58 59 int sepIndex = filepath.lastIndexOf(File.separator); 61 62 String filename = filepath.substring(sepIndex+1); 64 65 String [] parameters = filename.split("\\W"); 66 long l = Long.parseLong(parameters[0]); 67 String date = SessionNode.prettyDate(l); 68 String key = Property.LOG_FILE + date + ", " + level + ": "; 69 Property.addProperty(key, username); 70 71 return date; 72 } 73 74 75 } 76 | Popular Tags |