Produced by Araxis Merge on 6/20/2018 10:24:21 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | CCRS.zip\CCRS\Reports-Sprint_5.zip\Reports-Sprint_5-aa03f94869cda45ee08ca75641e61a7376f2c2a5\CCRSBaseHelper\src\main\java\gov\va\ccrs\helpers | TextFileHelper.java | Fri Mar 30 15:47:12 2018 UTC |
2 | CCRS.zip\CCRS\Reports-Sprint_5.zip\Reports-Sprint_5-aa03f94869cda45ee08ca75641e61a7376f2c2a5\CCRSBaseHelper\src\main\java\gov\va\ccrs\helpers | TextFileHelper.java | Fri Jun 15 13:11:39 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 356 |
Changed | 1 | 2 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | package go v.va.ccrs. helpers; | |
2 | ||
3 | import jav a.io.Buffe redWriter; | |
4 | import jav a.io.File; | |
5 | import jav a.io.FileI nputStream ; | |
6 | import jav a.io.FileW riter; | |
7 | import jav a.io.IOExc eption; | |
8 | import jav a.io.Input Stream; | |
9 | import jav a.text.Sim pleDateFor mat; | |
10 | import jav a.util.Dat e; | |
11 | import jav a.util.Pro perties; | |
12 | ||
13 | import org .apache.lo g4j.Level; | |
14 | ||
15 | /** | |
16 | * | |
17 | * Helper to retriev e a Handle text file s, Will al ways add t he date to the file name | |
18 | * | |
19 | * @author pi i
|
|
20 | * @versio n 1 | |
21 | * @since 12/08/2017 | |
22 | * | |
23 | */ | |
24 | ||
25 | public cla ss TextFil eHelper | |
26 | { | |
27 | privat e static F ile _file; | |
28 | privat e static S tring _fil eName = "" ; | |
29 | privat e static S tring _fil ePath = "" ; | |
30 | privat e static b oolean _is New = fals e; | |
31 | ||
32 | /** | |
33 | * | |
34 | * Sta tic Constr uctor | |
35 | * | |
36 | */ | |
37 | static | |
38 | { | |
39 | Pr operties p rop = new Properties (); | |
40 | In putStream input = nu ll; | |
41 | ||
42 | tr y | |
43 | { | |
44 | input = new FileIn putStream( ""); | |
45 | ||
46 | prop.loa d(input); | |
47 | ||
48 | _filePat h = prop.g etProperty ("filePath "); | |
49 | _fileNam e = prop.g etProperty ("fileName "); | |
50 | } | |
51 | ca tch (IOExc eption ex) | |
52 | { | |
53 | LogHelpe r.Log(Leve l.ERROR, e x); | |
54 | } | |
55 | fi nally | |
56 | { | |
57 | if (inpu t != null) | |
58 | { | |
59 | try | |
60 | { | |
61 | input.clos e(); | |
62 | } | |
63 | catc h (IOExcep tion e) | |
64 | { | |
65 | e.printSta ckTrace(); | |
66 | } | |
67 | } | |
68 | } | |
69 | } | |
70 | ||
71 | /** | |
72 | * | |
73 | * For mat Text f ile Name | |
74 | * | |
75 | */ | |
76 | privat e static v oid format FileName() | |
77 | { | |
78 | St ring dateF ormatted = new Simpl eDateForma t("yyyy-MM -dd").form at(new Dat e()); | |
79 | ||
80 | if (!_fileNam e.contains (dateForma tted)) | |
81 | { | |
82 | String f ileName = _fileName. substring( 0, _fileNa me.length( ) - 4); | |
83 | String f ileExt = _ fileName.s ubstring(_ fileName.l ength() - 4); | |
84 | ||
85 | fileName = fileNam e.concat(" _").concat (dateForma tted).conc at(fileExt ); | |
86 | ||
87 | _fileNam e = fileNa me; | |
88 | } | |
89 | } | |
90 | ||
91 | /** | |
92 | * | |
93 | * Cre ate Folder if it doe sn't exist | |
94 | * | |
95 | * @th rows IOExc eption | |
96 | */ | |
97 | privat e static v oid create FolderIfDo esntExist( ) throws I OException | |
98 | { | |
99 | _f ile = new File(_file Path); | |
100 | ||
101 | if (!_file.ex ists()) | |
102 | { | |
103 | _file.mk dir(); | |
104 | } | |
105 | } | |
106 | ||
107 | /** | |
108 | * | |
109 | * Cre ate Text F ile if it doesn't ex ist | |
110 | * | |
111 | * @th rows IOExc eption | |
112 | */ | |
113 | privat e static v oid create File() thr ows IOExce ption | |
114 | { | |
115 | _f ile = new File(_file Path, _fil eName); | |
116 | ||
117 | if (!_file.ex ists()) | |
118 | { | |
119 | _file.cr eateNewFil e(); | |
120 | _isNew = true; | |
121 | } | |
122 | el se | |
123 | { | |
124 | _isNew = false; | |
125 | } | |
126 | } | |
127 | ||
128 | /** | |
129 | * | |
130 | * Wri te Text to File, if file alrea dy exist, add new li ne first | |
131 | * | |
132 | * @pa ram text | |
133 | * @th rows IOExc eption | |
134 | */ | |
135 | privat e static v oid writeT ext(String text) thr ows IOExce ption | |
136 | { | |
137 | tr y( FileWri ter fileWr iter = new FileWrite r(_file.ge tAbsoluteF ile(), tru e); | |
138 | Buffere dWriter bu ffWriter = new Buffe redWriter( fileWriter ) | |
139 | ) | |
140 | { | |
141 | if(!_isN ew) | |
142 | { | |
143 | buff Writer.new Line(); | |
144 | } | |
145 | ||
146 | buffWrit er.write(n ew SimpleD ateFormat( "MM-dd-yyy y HH:mm:ss ").format( new Date() ).concat(" : ").conca t(text)); | |
147 | // buffWr iter.write ((text)); | |
148 | } | |
149 | ca tch(IOExce ption ex) | |
150 | { | |
151 | throw(ex ); | |
152 | } | |
153 | } | |
154 | ||
155 | /** | |
156 | * | |
157 | * Wri tes a text into a Te xt file, f ile name a nd path ar e defined | |
158 | * in the config .propertie s file (Fi leName and FilePath properties ) | |
159 | * | |
160 | * @pa ram text | |
161 | */ | |
162 | public static vo id WriteTe xt(String text) | |
163 | { | |
164 | tr y | |
165 | { | |
166 | formatFi leName(); | |
167 | ||
168 | createFo lderIfDoes ntExist(); | |
169 | ||
170 | createFi le(); | |
171 | ||
172 | writeTex t(text); | |
173 | } | |
174 | ca tch (IOExc eption ex) | |
175 | { | |
176 | LogHelpe r.Log(Leve l.ERROR, e x); | |
177 | } | |
178 | } | |
179 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.