Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature token vbl simplification #1307

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
186 commits
Select commit Hold shift + click to select a range
7040c4d
Merge pull request #983 from RPTools/release-1.5.8
JamzTheMan Dec 13, 2019
a7d2c6a
Bump okhttp from 4.2.2 to 4.3.0
dependabot-preview[bot] Jan 1, 2020
53531b1
Merge branch 'develop' into dependabot/gradle/develop/com.squareup.ok…
Phergus Jan 2, 2020
a8609e1
Merge pull request #1071 from RPTools/release-1.5.9
JamzTheMan Jan 3, 2020
76b4575
Merge branch 'develop' into dependabot/gradle/develop/com.squareup.ok…
JamzTheMan Jan 16, 2020
4f8fbc4
Merge branch 'develop' into dependabot/gradle/develop/com.squareup.ok…
JamzTheMan Jan 16, 2020
01369c5
Merge branch 'develop' into dependabot/gradle/develop/com.squareup.ok…
Phergus Jan 21, 2020
e80c4b7
Merge branch 'develop' into dependabot/gradle/develop/com.squareup.ok…
JamzTheMan Jan 24, 2020
b9dc7d7
Merge pull request #1202 from RPTools/1.5.12
JamzTheMan Jan 27, 2020
9d78045
Merge branch 'develop' into dependabot/gradle/develop/com.squareup.ok…
Phergus Jan 27, 2020
3091eae
New translations i18n.properties (Swedish)
rptools-automation Feb 4, 2020
d9ba1a4
New translations i18n.properties (German)
rptools-automation Feb 4, 2020
d1d0e90
New translations i18n.properties (Chinese Simplified)
rptools-automation Feb 4, 2020
4f0890f
New translations i18n.properties (Dutch)
rptools-automation Feb 4, 2020
6a835da
New translations i18n.properties (French)
rptools-automation Feb 4, 2020
3dbab14
New translations i18n.properties (Italian)
rptools-automation Feb 4, 2020
adff9a5
New translations i18n.properties (Japanese)
rptools-automation Feb 4, 2020
08ed4e0
New translations i18n.properties (Polish)
rptools-automation Feb 4, 2020
aa86a8f
New translations i18n.properties (Russian)
rptools-automation Feb 4, 2020
5bda626
New translations i18n.properties (Spanish)
rptools-automation Feb 4, 2020
5114a62
New translations i18n.properties (Japanese)
rptools-automation Feb 4, 2020
b3e4729
New translations i18n.properties (Russian)
rptools-automation Feb 4, 2020
7e49bcf
New translations i18n.properties (Japanese)
rptools-automation Feb 4, 2020
97d0302
New translations i18n.properties (Japanese)
rptools-automation Feb 4, 2020
22a6ee8
New translations i18n.properties (Russian)
rptools-automation Feb 5, 2020
7aa2d44
New translations i18n.properties (Russian)
rptools-automation Feb 5, 2020
2b9c63e
New translations i18n.properties (Dutch)
rptools-automation Feb 6, 2020
6e1ceb5
New translations i18n.properties (Dutch)
rptools-automation Feb 6, 2020
522bc1b
New translations i18n.properties (French)
rptools-automation Feb 6, 2020
464e6e7
Addressed thread safety issues in MD5Key
cwisniew Feb 7, 2020
68eef4f
Revert "Revert "Merge branch 'feature-mbl' of https://github.com/RPTo…
JamzTheMan Feb 7, 2020
c59425e
New translations i18n.properties (French)
rptools-automation Feb 7, 2020
a9a8473
Merge pull request #1251 from JamzTheMan/feature-mbl-revert-revert
Phergus Feb 7, 2020
791c8e2
Merge branch 'develop' into l18n_develop
Phergus Feb 7, 2020
496dedc
Merge pull request #1242 from RPTools/l18n_develop
Phergus Feb 7, 2020
6621b1d
spotless apply
cwisniew Feb 7, 2020
3d56fb6
Update CHANGE_LOG.md
Phergus Feb 7, 2020
0f15920
Merge branch 'develop' into fix-md5key-thread-safety
cwisniew Feb 7, 2020
5c439c2
Merge pull request #1254 from cwisniew/fix-md5key-thread-safety
Phergus Feb 7, 2020
7cff571
Update CHANGE_LOG.md
Phergus Feb 7, 2020
96ef475
Merge branch 'develop' into Changelog160update2
Phergus Feb 7, 2020
b582f01
Merge pull request #1255 from RPTools/Changelog160update2
cwisniew Feb 7, 2020
7b21dac
Update .appveyor.yml
Phergus Feb 7, 2020
aac49bc
Merge pull request #1256 from RPTools/appveyorForceUpdateFix
Azhrei Feb 7, 2020
04ecd20
Remove duplicate code
JamzTheMan Feb 7, 2020
af6dd36
Merge pull request #1257 from JamzTheMan/develop
Phergus Feb 7, 2020
4132019
Update MapTool.java
Phergus Feb 7, 2020
b0e507c
Merge branch 'develop' into setCampaignFix
Phergus Feb 7, 2020
4b7d2f2
Update MapTool.java
Phergus Feb 7, 2020
a02ae1a
Merge branch 'develop' of https://github.com/RPTools/maptool into set…
Phergus Feb 7, 2020
a4bcd5d
Merge branch 'setCampaignFix' of https://github.com/Phergus/maptool i…
Phergus Feb 7, 2020
8d21f00
Merge pull request #1258 from Phergus/setCampaignFix
JamzTheMan Feb 7, 2020
f903ec0
Properly handles the case when the directory is not writable
emmebi Feb 7, 2020
b58ca18
Properly handles the case when the directory is not writable
emmebi Feb 7, 2020
ad73362
Merge branch 'issue-1231' into develop
emmebi Feb 7, 2020
8997245
Merge branch 'develop' into develop
Phergus Feb 7, 2020
00d5399
Merge pull request #1259 from emmebi/develop
Phergus Feb 7, 2020
c671772
Fix hessian exception during start up
cwisniew Feb 7, 2020
04a0f2a
Merge pull request #1260 from cwisniew/fix-hessian-md5key-startup-exc…
Phergus Feb 7, 2020
42bc75a
New translations i18n.properties (Swedish)
rptools-automation Feb 7, 2020
a515181
New translations i18n.properties (German)
rptools-automation Feb 7, 2020
f981fb5
New translations i18n.properties (Chinese Simplified)
rptools-automation Feb 7, 2020
08fd1cc
New translations i18n.properties (Dutch)
rptools-automation Feb 7, 2020
9970045
New translations i18n.properties (French)
rptools-automation Feb 7, 2020
ff9ad04
New translations i18n.properties (Italian)
rptools-automation Feb 7, 2020
781f49c
New translations i18n.properties (Japanese)
rptools-automation Feb 7, 2020
a46e560
New translations i18n.properties (Polish)
rptools-automation Feb 7, 2020
e869a5b
New translations i18n.properties (Russian)
rptools-automation Feb 7, 2020
8b058d3
New translations i18n.properties (Spanish)
rptools-automation Feb 7, 2020
93e4714
Update CHANGE_LOG.md
Phergus Feb 7, 2020
b22340f
Merge pull request #1262 from RPTools/ChangelogUpdate3
Phergus Feb 7, 2020
f477274
Decouples AssetPanel from Resource window so that each one can browse…
emmebi Feb 8, 2020
13b83fe
Merge branch 'issue-256' into develop
emmebi Feb 8, 2020
cc16f5a
Merge branch 'develop' of https://github.com/emmebi/maptool into develop
emmebi Feb 8, 2020
64b6370
Merge branch 'develop' into develop
JamzTheMan Feb 8, 2020
dd39a88
Merge pull request #1266 from emmebi/develop
Phergus Feb 8, 2020
bb80a0d
New translations i18n.properties (Dutch)
rptools-automation Feb 9, 2020
9eb5a9d
Fixes for NPE on AutoSave and Load
cwisniew Feb 9, 2020
f0ce55b
New translations i18n.properties (Dutch)
rptools-automation Feb 9, 2020
d58121b
New translations i18n.properties (Russian)
rptools-automation Feb 10, 2020
ce0f901
Cleanup of confirmation dialog for deleting a drawing
Phergus Feb 10, 2020
43cc576
Adds AutoCloseable interface to PackedFile
emmebi Feb 10, 2020
b864c29
Removed spurious Shape variable
cwisniew Feb 10, 2020
e209520
Merge branch 'develop' into fix-1267
cwisniew Feb 10, 2020
8c796fb
Merge pull request #1273 from cwisniew/fix-1267
Phergus Feb 10, 2020
7960359
Merge branch 'develop' into confirmDwgDelete
Phergus Feb 10, 2020
096ef12
Substitures try/finally with try-with-resources for PackedFile
emmebi Feb 11, 2020
eed74e7
Merge branch 'issue-1215' into develop
emmebi Feb 11, 2020
44cb98e
Fixed getShapedArea(...) so it now returns the an Area that conforms …
JamzTheMan Feb 9, 2020
55c792f
Merge branch 'develop' of https://github.com/RPTools/maptool into fea…
JamzTheMan Feb 12, 2020
af40afc
Fixed getShapedArea(...) so it now returns the an Area that conforms …
JamzTheMan Feb 12, 2020
8eb50a1
Merge pull request #1275 from JamzTheMan/feature-grid-hex-lights
Phergus Feb 12, 2020
bff0382
Merge branch 'develop' into develop
cwisniew Feb 12, 2020
16c9dac
Merge pull request #1274 from emmebi/develop
Phergus Feb 12, 2020
1e87dd5
Merge branch 'develop' into confirmDwgDelete
Phergus Feb 12, 2020
206a927
Merge pull request #1272 from Phergus/confirmDwgDelete
Azhrei Feb 12, 2020
62f1073
New translations i18n.properties (Swedish)
rptools-automation Feb 13, 2020
6f22922
New translations i18n.properties (German)
rptools-automation Feb 13, 2020
94b8276
New translations i18n.properties (Chinese Simplified)
rptools-automation Feb 13, 2020
8821264
New translations i18n.properties (Dutch)
rptools-automation Feb 13, 2020
6319104
New translations i18n.properties (French)
rptools-automation Feb 13, 2020
809d48a
New translations i18n.properties (Italian)
rptools-automation Feb 13, 2020
6b8dedf
New translations i18n.properties (Japanese)
rptools-automation Feb 13, 2020
d3d669e
New translations i18n.properties (Polish)
rptools-automation Feb 13, 2020
24c729a
New translations i18n.properties (Russian)
rptools-automation Feb 13, 2020
dce8754
New translations i18n.properties (Spanish)
rptools-automation Feb 13, 2020
7be09dd
Merge branch 'develop' into l18n_develop
JamzTheMan Feb 13, 2020
8b62b44
New translations i18n.properties (French)
rptools-automation Feb 13, 2020
9e76c49
Merge pull request #1261 from RPTools/l18n_develop
Phergus Feb 14, 2020
148a6c1
Change hardcoded WalkerMetric for GRID
JamzTheMan Feb 14, 2020
03391a3
Merge pull request #1277 from JamzTheMan/develop
Phergus Feb 14, 2020
3ae20b1
New translations i18n.properties (Russian)
rptools-automation Feb 15, 2020
ecd148e
Fix input() PROPS type not working
Merudo Feb 15, 2020
1637669
Removes uses of the deprecated IOUtils.closeQuietly
emmebi Feb 15, 2020
3b3c222
Removes last use of copyWithClose left from previous commit
emmebi Feb 15, 2020
f41fdb4
Removes last use of copyWithClose left from previous commit
emmebi Feb 15, 2020
edaa0b7
New translations i18n.properties (Russian)
rptools-automation Feb 15, 2020
6a23e51
Merge pull request #1280 from Merudo/fix-input-props
Phergus Feb 15, 2020
7522771
Merge branch 'develop' into dependabot/gradle/develop/com.squareup.ok…
JamzTheMan Feb 15, 2020
5a590bd
Merge branch 'develop' into issue-1215
Phergus Feb 15, 2020
515ddf0
Merge pull request #1281 from emmebi/issue-1215
Phergus Feb 15, 2020
3c70c21
Merge branch 'develop' into dependabot/gradle/develop/com.squareup.ok…
Phergus Feb 15, 2020
7553119
Add json support to input PROPS for label and value
Merudo Feb 15, 2020
1633f8d
Merge pull request #1061 from RPTools/dependabot/gradle/develop/com.s…
Phergus Feb 15, 2020
2ecc66f
Merge branch 'develop' into feature-input-propsjson
Phergus Feb 15, 2020
4f42ad3
Merge pull request #1283 from Merudo/feature-input-propsjson
Phergus Feb 15, 2020
99f2d29
Remove superfluous ParserException declarations
Merudo Feb 15, 2020
68015fc
Merge pull request #1285 from Merudo/maintenance-remove-parserexceptions
Phergus Feb 16, 2020
4df6294
Add option TYPE=JSON to input() PROPS
Merudo Feb 16, 2020
55fa8a4
Merge pull request #1286 from Merudo/feature-input-props-json
Phergus Feb 16, 2020
78a3d92
Toolbar refactor for AI & Topology Section tools
JamzTheMan Feb 16, 2020
55e6cbf
Merge branch 'develop' into toolbar-refactor
JamzTheMan Feb 16, 2020
82f85bc
Removes the empty space at the bottom of input() dialog
emmebi Feb 16, 2020
a5380cd
Fix for when layer argument to getTokenNames is not an array
cwisniew Jan 27, 2020
9ff4716
Minor json code clean up and trapping when function isnt defined
cwisniew Jan 28, 2020
22d245f
Update src/main/java/net/rptools/maptool/client/functions/json/JSONMa…
cwisniew Jan 28, 2020
e569aaa
Fix for various TokenMoveFunctions that rely on pathPointsToJSONArray…
JamzTheMan Feb 2, 2020
a6b4231
fix for get tokens with set or unset state
cwisniew Feb 4, 2020
c25c256
Merge branch 'develop' into tabs-in-input-function
Phergus Feb 16, 2020
885a725
Merge pull request #1287 from JamzTheMan/toolbar-refactor
Phergus Feb 17, 2020
e32fa94
New translations i18n.properties (Swedish)
rptools-automation Feb 17, 2020
e27fdbe
New translations i18n.properties (German)
rptools-automation Feb 17, 2020
cac8272
New translations i18n.properties (Chinese Simplified)
rptools-automation Feb 17, 2020
be1bc3e
New translations i18n.properties (Dutch)
rptools-automation Feb 17, 2020
6e22409
New translations i18n.properties (French)
rptools-automation Feb 17, 2020
fda0f6d
New translations i18n.properties (Italian)
rptools-automation Feb 17, 2020
d4326c5
New translations i18n.properties (Japanese)
rptools-automation Feb 17, 2020
2f35eee
New translations i18n.properties (Polish)
rptools-automation Feb 17, 2020
00c883f
New translations i18n.properties (Russian)
rptools-automation Feb 17, 2020
b706135
New translations i18n.properties (Spanish)
rptools-automation Feb 17, 2020
9be94e3
Merge branch 'develop' into tabs-in-input-function
Phergus Feb 17, 2020
ccca741
Rehost JDK
cwisniew Feb 17, 2020
bb08d61
Rehost JDK
cwisniew Feb 17, 2020
69af22d
Merge pull request #1290 from RPTools/fix-rehost-jdk
Phergus Feb 17, 2020
fb10fe0
Merge branch 'develop' into tabs-in-input-function
Phergus Feb 17, 2020
ec08e01
Update Change Log for 1.5.13 release
Phergus Feb 17, 2020
5aa3cf5
New translations i18n.properties (Japanese)
rptools-automation Feb 17, 2020
4e40c2a
New translations i18n.properties (Japanese)
rptools-automation Feb 17, 2020
063e385
Fixes problem with extension not being always added to Campaign filen…
emmebi Feb 18, 2020
746cfa8
Removes an unneeded import.
emmebi Feb 18, 2020
161302c
Fix getTokens option setStates returning wrong data
Merudo Feb 19, 2020
88a71c4
Merge pull request #1295 from Merudo/fix-getTokens-setStates
Phergus Feb 19, 2020
77f3b87
Bug fix for NPE when Hero Lab XML data missing
JamzTheMan Feb 19, 2020
117f7bf
Merge branch 'develop' into campaign-short-names
Phergus Feb 19, 2020
3d6e863
Bug fix for NPE when Hero Lab XML data missing
JamzTheMan Feb 19, 2020
ca18dc4
Merge pull request #1297 from JamzTheMan/bug-herolab-xml
Phergus Feb 19, 2020
f67909a
Merge pull request #1294 from emmebi/campaign-short-names
Phergus Feb 19, 2020
60777e2
Merge branch 'develop' into tabs-in-input-function
Phergus Feb 19, 2020
b051ba6
Update CHANGE_LOG.md
Phergus Feb 19, 2020
07dbdd2
Merge pull request #1289 from emmebi/tabs-in-input-function
Phergus Feb 19, 2020
7388ec0
Fix getTokens option setStates returning wrong data
Merudo Feb 19, 2020
6d3e25c
Merge branch 'rel-1.5.13' of https://github.com/RPTools/maptool into …
Phergus Feb 19, 2020
25ad55f
New translations i18n.properties (Swedish)
rptools-automation Feb 20, 2020
31ad699
New translations i18n.properties (Swedish)
rptools-automation Feb 20, 2020
fa024db
Merge branch 'develop' into l18n_develop
Phergus Feb 20, 2020
7dabbb0
Update TokenCopyDeleteFunctions.java
Phergus Feb 20, 2020
24f799e
Merge pull request #1279 from RPTools/l18n_develop
Phergus Feb 20, 2020
db6e054
Merge branch 'develop' into issue1300copyTokens
Phergus Feb 20, 2020
39ec90e
Merge branch 'master' into rel-1.5.13
JamzTheMan Feb 20, 2020
1707cb1
Merge branch 'develop' into rel-1.5.13
JamzTheMan Feb 21, 2020
7ad676c
Merge pull request #1301 from Phergus/issue1300copyTokens
JamzTheMan Feb 21, 2020
ca1261c
Merge branch 'develop' into rel-1.5.13
JamzTheMan Feb 21, 2020
5f448a0
Merge pull request #1303 from RPTools/rel-1.5.13
Phergus Feb 21, 2020
0e847a0
Merge branch 'feature-token-vbl-simplification' of https://github.com…
JamzTheMan Feb 21, 2020
8ffdbba
WIP - Optimized TokenVBL
JamzTheMan Feb 22, 2020
76e2888
WIP - Optimized TokenVBL
JamzTheMan Feb 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ deploy:
artifact: MapTool-Jar, MapTool-Windows, MapTool-Linux
draft: false
prerelease: true
force_update: true
force_update: false
on:
APPVEYOR_REPO_TAG: true
on_success:
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ install:
- cd ..
- mkdir java
- cd java
- wget http://www.nerps.net/jdk10/jdk-10.0.2_osx-x64_bin.dmg
- wget http://maptool.craigs-stuff.net/java/jdk-10.0.2_osx-x64_bin.dmg
- MOUNTDEV=$(hdiutil mount jdk-10.0.2_osx-x64_bin.dmg | awk '/dev.disk/{print$1}')
- echo $MOUNTDEV
- MOUNTDIR="$(mount | grep JDK | awk '{$1=$2="";sub(" [(].*","");sub("^ ","");print}')"
Expand Down
23 changes: 23 additions & 0 deletions CHANGE_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ Maptool 1.6.0
=====
**Highlights**
- New dialog and frame functions support HTML5, JavaScript and CSS.
- Movement Blocking Layer - Now you can make those Force Fields that would block movement but not sight.
- Look & Feel themes can now be selected from the Themes menu. More enhancements to come.
- Pre-defined Campaign Property sets can now be selected and loaded in the Campaign Properties dialog.

**Enhancements**
- [#1216][i1216] Movement Blocking Layer - similar VBL, but specifically for blocking movement and not sight or light.
- [#1210][i1210] RADIO and LIST fields for `input()` function now support a DELIMITER option.
- [#1107][i1107] Using the line drawing tools while holding Alt will snap to grid centers.
- [#972][i972] New macro functions for HTML5 compatible dialogs and frames.
Expand All @@ -25,15 +27,18 @@ Maptool 1.6.0
- [#1204][i1204] `getToken*` was throwing an exception if a string was passed to the `layer` option. Fixed.

**Other**
- [#1253][i1253] MD5 key generation wasn't thread-safe. Fixed.
- [#1219][i1219] Javadocs generated via `gradlew javadoc` switched to HTML5.
- [#1189][i1189] Unit tests added for JSON macro functions.

[i1253]: https://github.com/RPTools/maptool/issues/1253
[i1243]: https://github.com/RPTools/maptool/issues/1243
[i1236]: https://github.com/RPTools/maptool/issues/1236
[i1231]: https://github.com/RPTools/maptool/issues/1231
[i1228]: https://github.com/RPTools/maptool/issues/1228
[i1225]: https://github.com/RPTools/maptool/issues/1225
[i1219]: https://github.com/RPTools/maptool/issues/1219
[i1216]: https://github.com/RPTools/maptool/issues/1216
[i1210]: https://github.com/RPTools/maptool/issues/1210
[i1206]: https://github.com/RPTools/maptool/issues/1206
[i1204]: https://github.com/RPTools/maptool/issues/1204
Expand All @@ -44,6 +49,24 @@ Maptool 1.6.0
[i891]: https://github.com/RPTools/maptool/issues/891
[i221]: https://github.com/RPTools/maptool/issues/221

Maptool 1.5.13
=====
**Highlights**
- Bug fix release to correct several JSON related issues.

**Bug Fixes**
- [#1296][i1296] Exception thrown when trying to read Hero Lab .por files that are missing the XML statblock. Exception caught and error reported.
- [#1236][i1236] `getTokens/getTokenNames()` was failing if `setState` or `unsetState` options were used. Fixed.
- [#1228][i1228] `getLastPath()` and other token move functions that made use of pathPointsToJsonArray were broken. Fixed.
- [#1206][i1206] Unknown json functions would return null instead of an error. Fixed.
- [#1204][i1204] Layer condition of `getTokens/getTokenNames()` weren't accepting accepting a string for a single layer. Fixed.

[i1296]: https://github.com/RPTools/maptool/issues/1296
[i1236]: https://github.com/RPTools/maptool/issues/1236
[i1228]: https://github.com/RPTools/maptool/issues/1228
[i1206]: https://github.com/RPTools/maptool/issues/1206
[i1204]: https://github.com/RPTools/maptool/issues/1204

Maptool 1.5.11/12
=====
**Highlights**
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ dependencies {
implementation group: 'org.locationtech.jts', name: 'jts-core', version: '1.16.1' // https://mvnrepository.com/artifact/org.locationtech.jts/jts-core

// For RESTful functions
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.2.2'
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.3.0'

// Better JSON functions...
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6' // https://mvnrepository.com/artifact/com.google.code.gson/gson
Expand Down
87 changes: 23 additions & 64 deletions src/main/java/net/rptools/lib/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,37 +84,24 @@ public static byte[] getBytes(File file) throws IOException {

public static Object objFromResource(String res) throws IOException {
XStream xs = getConfiguredXStream();
InputStream is = null;
try {
is = FileUtil.class.getClassLoader().getResourceAsStream(res);
try (InputStream is = FileUtil.class.getClassLoader().getResourceAsStream(res)) {
return xs.fromXML(new InputStreamReader(is, "UTF-8"));
} finally {
IOUtils.closeQuietly(is);
}
}

public static byte[] loadResource(String resource) throws IOException {
InputStream is = null;
try {
is = FileUtil.class.getClassLoader().getResourceAsStream(resource);
try (InputStream is = FileUtil.class.getClassLoader().getResourceAsStream(resource)) {
if (is == null) {
throw new IOException("Resource \"" + resource + "\" cannot be opened as stream.");
}
return IOUtils.toByteArray(new InputStreamReader(is, "UTF-8"), "UTF-8");
} finally {
IOUtils.closeQuietly(is);
}
}

public static List<String> getLines(File file) throws IOException {
List<String> list;
FileReader fr = new FileReader(file);
try {
list = IOUtils.readLines(fr);
} finally {
fr.close();
try (FileReader fr = new FileReader(file)) {
return IOUtils.readLines(fr);
}
return list;
}

public static void saveResource(String resource, File destDir) throws IOException {
Expand All @@ -126,15 +113,9 @@ public static void saveResource(String resource, File destDir) throws IOExceptio
public static void saveResource(String resource, File destDir, String filename)
throws IOException {
File outFilename = new File(destDir, filename);
InputStream inStream = null;
OutputStream outStream = null;
try {
inStream = FileUtil.class.getResourceAsStream(resource);
outStream = new BufferedOutputStream(new FileOutputStream(outFilename));
try (InputStream inStream = FileUtil.class.getResourceAsStream(resource);
OutputStream outStream = new BufferedOutputStream(new FileOutputStream(outFilename))) {
IOUtils.copy(inStream, outStream);
} finally {
IOUtils.closeQuietly(inStream);
IOUtils.closeQuietly(outStream);
}
}

Expand Down Expand Up @@ -170,12 +151,8 @@ public static String getNameWithoutExtension(URL url) {
}

public static byte[] getBytes(URL url) throws IOException {
InputStream is = null;
try {
is = url.openStream();
try (InputStream is = url.openStream()) {
return IOUtils.toByteArray(is);
} finally {
IOUtils.closeQuietly(is);
}
}

Expand Down Expand Up @@ -374,12 +351,8 @@ public static void unzip(URL url, File destDir) throws IOException {
if (url == null) throw new IOException("URL cannot be null");

InputStream is = url.openStream();
ZipInputStream zis = null;
try {
zis = new ZipInputStream(new BufferedInputStream(is));
try (ZipInputStream zis = new ZipInputStream(new BufferedInputStream(is))) {
unzip(zis, destDir);
} finally {
IOUtils.closeQuietly(zis);
}
}

Expand All @@ -391,34 +364,25 @@ public static void unzip(ZipInputStream in, File destDir) throws IOException {
File absDestDir = destDir.getAbsoluteFile();

// Pull out the files
OutputStream out = null;
ZipEntry entry = null;
try {
while ((entry = in.getNextEntry()) != null) {
if (entry.isDirectory()) continue;
while ((entry = in.getNextEntry()) != null) {
if (entry.isDirectory()) continue;

// Prepare file destination
File entryFile = new File(absDestDir, entry.getName());
entryFile.getParentFile().mkdirs();
// Prepare file destination
File entryFile = new File(absDestDir, entry.getName());
entryFile.getParentFile().mkdirs();

out = new FileOutputStream(entryFile);
try (OutputStream out = new FileOutputStream(entryFile)) {
IOUtils.copy(in, out);
IOUtils.closeQuietly(out);
in.closeEntry();
}
} finally {
IOUtils.closeQuietly(out);
in.closeEntry();
}
}

public static void unzipFile(File sourceFile, File destDir) throws IOException {
if (!sourceFile.exists()) throw new IOException("source file does not exist: " + sourceFile);

ZipFile zipFile = null;
InputStream is = null;
OutputStream os = null;
try {
zipFile = new ZipFile(sourceFile);
try (ZipFile zipFile = new ZipFile(sourceFile)) {
Enumeration<? extends ZipEntry> entries = zipFile.entries();

while (entries.hasMoreElements()) {
Expand All @@ -430,18 +394,10 @@ public static void unzipFile(File sourceFile, File destDir) throws IOException {
file.getParentFile().mkdirs();

// System.out.println("Writing file: " + path);
is = zipFile.getInputStream(entry);
os = new BufferedOutputStream(new FileOutputStream(path));
copyWithClose(is, os);
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);
}
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);
try {
if (zipFile != null) zipFile.close();
} catch (Exception e) {
try (InputStream is = zipFile.getInputStream(entry);
OutputStream os = new BufferedOutputStream(new FileOutputStream(path))) {
IOUtils.copy(is, os);
}
}
}
}
Expand All @@ -462,10 +418,13 @@ public static void copyWithoutClose(InputStream is, OutputStream os) throws IOEx
/**
* Copies all bytes from InputStream to OutputStream, and close both streams before returning.
*
* @deprecated not in use. Use {@link IOUtils#copy(InputStream, OutputStream)} instead and
* try-with-resources
* @param is input stream to read data from.
* @param os output stream to write data to.
* @throws IOException
*/
@Deprecated
public static void copyWithClose(InputStream is, OutputStream os) throws IOException {
try {
IOUtils.copy(is, os);
Expand Down
Loading