Produced by Araxis Merge on 6/20/2018 10:24:20 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 | CompressionHelper.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 | CompressionHelper.java | Fri Jun 15 13:12:14 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 326 |
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.FileI nputStream ; | |
4 | import jav a.io.FileO utputStrea m; | |
5 | import jav a.io.IOExc eption; | |
6 | import jav a.io.Input Stream; | |
7 | import jav a.util.Pro perties; | |
8 | import jav a.util.zip .GZIPInput Stream; | |
9 | import jav a.util.zip .ZipInputS tream; | |
10 | ||
11 | import org .apache.lo g4j.Level; | |
12 | ||
13 | /** | |
14 | * | |
15 | * Helper to uncompr ess (compr ession wil l be imple mented lat er) .zip a nd .gz | |
16 | * files i n their fo lder | |
17 | * | |
18 | * @author PII | |
19 | * @versio n 1 | |
20 | * @since 11/22/2017 | |
21 | * | |
22 | */ | |
23 | ||
24 | public cla ss Compres sionHelper | |
25 | { | |
26 | privat e static S tring _fil eExt; | |
27 | privat e static S tring _unz ipFileExt; | |
28 | ||
29 | /** | |
30 | * | |
31 | * Com pression H elper stat ic constru ctor | |
32 | * | |
33 | * Rea ds configu ration fil e and load s the conf iguration informatio n into | |
34 | * var iables. | |
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( "config.pr operties") ; | |
45 | ||
46 | prop.loa d(input); | |
47 | ||
48 | _fileExt = prop.ge tProperty( "Compressf ileExt"); | |
49 | _unzipFi leExt = pr op.getProp erty("Unco mpressfile Ext"); | |
50 | } | |
51 | ca tch (IOExc eption ex) | |
52 | { | |
53 | LogHelpe r.Log(Leve l.ERROR, e x); | |
54 | // ex.pr intStackTr ace(); | |
55 | } | |
56 | fi nally | |
57 | { | |
58 | if (inpu t != null) | |
59 | { | |
60 | try | |
61 | { | |
62 | input.clos e(); | |
63 | } | |
64 | catc h (IOExcep tion e) | |
65 | { | |
66 | e.printSta ckTrace(); | |
67 | } | |
68 | } | |
69 | } | |
70 | } | |
71 | ||
72 | /** | |
73 | * | |
74 | * For mats the f ile Name a nd changes the exten sion to Js on | |
75 | * | |
76 | * @pa ram fileNa me | |
77 | * @re turn | |
78 | */ | |
79 | privat e static S tring form atOutputFi leName(Str ing fileNa me) | |
80 | { | |
81 | St ring outpu tFileName = fileName ; | |
82 | ||
83 | ou tputFileNa me = outpu tFileName. substring( 0, fileNam e.length() - _fileEx t.length() ); | |
84 | ||
85 | if (!outputFi leName.end sWith(_unz ipFileExt) ) | |
86 | { | |
87 | outputFi leName = o utputFileN ame.concat (_unzipFil eExt); | |
88 | } | |
89 | ||
90 | re turn(outpu tFileName) ; | |
91 | } | |
92 | ||
93 | /** | |
94 | * | |
95 | * Unc ompresses a .gz file into the current fo lder | |
96 | * | |
97 | * @pa ram fileNa me | |
98 | */ | |
99 | public static vo id gzUnzip (String fi leName) | |
100 | { | |
101 | by te[] buffe r = new by te[1024]; | |
102 | ||
103 | St ring outpu tFileName = formatOu tputFileNa me(fileNam e); | |
104 | ||
105 | tr y | |
106 | { | |
107 | GZIPInpu tStream gz ip = new G ZIPInputSt ream(new F ileInputSt ream(fileN ame)); | |
108 | ||
109 | FileOutp utStream o ut = new F ileOutputS tream(outp utFileName ); | |
110 | ||
111 | int len; | |
112 | ||
113 | while (( len = gzip .read(buff er)) > 0) | |
114 | { | |
115 | out. write(buff er, 0, len ); | |
116 | } | |
117 | ||
118 | gzip.clo se(); | |
119 | ||
120 | out.clos e(); | |
121 | } | |
122 | ca tch (IOExc eption ex) | |
123 | { | |
124 | LogHelpe r.Log(Leve l.ERROR, e x); | |
125 | // ex.pr intStackTr ace(); | |
126 | } | |
127 | } | |
128 | ||
129 | /** | |
130 | * | |
131 | * Unc ompresses a .zip fil e into the current f older | |
132 | * | |
133 | * @pa ram fileNa me | |
134 | */ | |
135 | public static vo id unZip(S tring file Name) | |
136 | { | |
137 | by te[] buffe r = new by te[1024]; | |
138 | ||
139 | St ring outpu tFileName = formatOu tputFileNa me(fileNam e); | |
140 | ||
141 | tr y | |
142 | { | |
143 | ZipInput Stream zip = new Zip InputStrea m(new File InputStrea m(fileName )); | |
144 | ||
145 | FileOutp utStream o ut = new F ileOutputS tream(outp utFileName ); | |
146 | ||
147 | int len; | |
148 | ||
149 | while (( len = zip. read(buffe r)) > 0) | |
150 | { | |
151 | out. write(buff er, 0, len ); | |
152 | } | |
153 | ||
154 | zip.clos e(); | |
155 | ||
156 | out.clos e(); | |
157 | } | |
158 | ca tch (IOExc eption ex) | |
159 | { | |
160 | LogHelpe r.Log(Leve l.ERROR, e x); | |
161 | // ex.pr intStackTr ace(); | |
162 | } | |
163 | } | |
164 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.