Mercurial > hg > Members > nobuyasu > jungle-network
comparison src/main/java/alice/jungle/persistent/PersistentJournal.java @ 169:54d68cda84c4
create edit Attribute & Folder Method
author | tatsuki |
---|---|
date | Tue, 29 Jul 2014 18:51:44 +0900 |
parents | cd4d64249931 |
children |
comparison
equal
deleted
inserted
replaced
168:91f6dd655a01 | 169:54d68cda84c4 |
---|---|
16 | 16 |
17 // private ChangeListWriter WRITER; | 17 // private ChangeListWriter WRITER; |
18 private ChangeListReader READER; | 18 private ChangeListReader READER; |
19 private OutputStream out; | 19 private OutputStream out; |
20 private InputStream in; | 20 private InputStream in; |
21 private String logFileName; | |
21 | 22 |
22 public PersistentJournal() { | 23 public PersistentJournal() { |
23 } | 24 } |
24 | 25 |
25 public PersistentJournal(File file) throws FileNotFoundException { | 26 public PersistentJournal(File file) throws FileNotFoundException { |
26 out = new FileOutputStream(file,true); | 27 out = new FileOutputStream(file,true); |
27 in = new FileInputStream(file); | 28 in = new FileInputStream(file); |
28 // WRITER = new PersistentChangeListWriter(out); | 29 //「 WRITER = new PersistentChangeListWriter(out); |
29 READER = new PersistentChangeListReader(in); | 30 READER = new PersistentChangeListReader(in); |
30 } | 31 } |
31 | 32 |
32 @Override | 33 @Override |
33 public ChangeListReader getReader() { | 34 public ChangeListReader getReader() { |
35 } | 36 } |
36 | 37 |
37 @Override | 38 @Override |
38 public ChangeListWriter getWriter() { | 39 public ChangeListWriter getWriter() { |
39 String timeStamp = Long.toString(System.currentTimeMillis()); | 40 String timeStamp = Long.toString(System.currentTimeMillis()); |
40 String logFileName = timeStamp + ".log"; | 41 logFileName = timeStamp + ".log"; |
41 OutputStream outStream = null; | 42 OutputStream outStream = null; |
42 try { | 43 try { |
43 outStream = new FileOutputStream(new File("./log/"+logFileName)); | 44 outStream = new FileOutputStream(new File("./log/"+logFileName)); |
44 } catch (FileNotFoundException e) { | 45 } catch (FileNotFoundException e) { |
45 e.printStackTrace(); | 46 e.printStackTrace(); |
72 | 73 |
73 public InputStream getInputStream() { | 74 public InputStream getInputStream() { |
74 return in; | 75 return in; |
75 } | 76 } |
76 | 77 |
78 public String getLogName(){ | |
79 return logFileName; | |
80 } | |
81 | |
77 public void close() throws IOException { | 82 public void close() throws IOException { |
78 out.close(); | 83 out.close(); |
79 in.close(); | 84 in.close(); |
80 } | 85 } |
81 } | 86 } |