Commit cea7522 1 parent 5ecf22c commit cea7522 Copy full SHA for cea7522
File tree 3 files changed +22
-7
lines changed
src/main/java/com/vimasig/bozar/obfuscator
3 files changed +22
-7
lines changed Original file line number Diff line number Diff line change 3
3
<modelVersion >4.0.0</modelVersion >
4
4
<groupId >com.vimasig</groupId >
5
5
<artifactId >Bozar</artifactId >
6
- <version >1.2.0 </version >
6
+ <version >1.2.1 </version >
7
7
<properties >
8
8
<project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
9
9
<maven .compiler.source>14</maven .compiler.source>
Original file line number Diff line number Diff line change 2
2
3
3
import com .vimasig .bozar .obfuscator .transformer .TransformManager ;
4
4
import com .vimasig .bozar .obfuscator .utils .StreamUtils ;
5
+ import com .vimasig .bozar .obfuscator .utils .StringUtils ;
5
6
import com .vimasig .bozar .obfuscator .utils .model .BozarConfig ;
6
7
import com .vimasig .bozar .obfuscator .utils .model .BozarMessage ;
7
8
import com .vimasig .bozar .obfuscator .utils .model .CustomClassWriter ;
@@ -124,12 +125,9 @@ public void run() {
124
125
log ("Done. Took %ss" , timeElapsed );
125
126
126
127
// File size information
127
- float rate = (float )output .toFile ().length () / (float )input .length ();
128
- float percentage = rate * 100 - 100 ;
129
- final String percentageStr = new DecimalFormat ("##.##" ).format (Math .abs (percentage ));
130
- if (percentage == 0 ) log ("File size didn't change." );
131
- else if (percentage > 0 ) log ("File size increased by %s%%" , percentageStr );
132
- else log ("File size decreased by %s%%" , percentageStr );
128
+ final String oldSize = StringUtils .getConvertedSize (input .length ());
129
+ final String newSize = StringUtils .getConvertedSize (output .toFile ().length ());
130
+ log ("File size changed from %s to %s" , oldSize , newSize );
133
131
} catch (IOException e ) {
134
132
e .printStackTrace ();
135
133
}
Original file line number Diff line number Diff line change 1
1
package com .vimasig .bozar .obfuscator .utils ;
2
2
3
+ import java .text .CharacterIterator ;
4
+ import java .text .StringCharacterIterator ;
3
5
import java .util .stream .Collectors ;
4
6
import java .util .stream .IntStream ;
5
7
@@ -12,4 +14,19 @@ public static String getAlphabet() {
12
14
.map (String ::valueOf )
13
15
.collect (Collectors .joining ());
14
16
}
17
+
18
+ public static String getConvertedSize (long bytes ) {
19
+ long absB = bytes == Long .MIN_VALUE ? Long .MAX_VALUE : Math .abs (bytes );
20
+ if (absB < 1024 ) {
21
+ return bytes + " B" ;
22
+ }
23
+ long value = absB ;
24
+ CharacterIterator ci = new StringCharacterIterator ("KMGTPE" );
25
+ for (int i = 40 ; i >= 0 && absB > 0xfffccccccccccccL >> i ; i -= 10 ) {
26
+ value >>= 10 ;
27
+ ci .next ();
28
+ }
29
+ value *= Long .signum (bytes );
30
+ return String .format ("%.1f %cB" , value / 1024.0 , ci .current ());
31
+ }
15
32
}
You can’t perform that action at this time.
0 commit comments