-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from project-husky/develop
Migrate fix for release 2.5.0
- Loading branch information
Showing
2 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...mmunication/husky-valueset-gen/src/main/java/org/projecthusky/valueset/utils/VsUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* | ||
*/ | ||
package org.projecthusky.valueset.utils; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URL; | ||
import java.net.URLConnection; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
|
||
/** | ||
* | ||
*/ | ||
public class VsUtils { | ||
|
||
/** | ||
* Method to download as a string | ||
* | ||
* @param url | ||
* the url to download form | ||
* @return the string of the downloaded content | ||
* @throws IOException | ||
* occures on errors during download | ||
*/ | ||
public static String downloadAsString(URL url) throws IOException { | ||
URLConnection connection = url.openConnection(); | ||
connection.setRequestProperty("User-Agent", "Mozilla/5.0 Gecko/20100316 Firefox/3.6.2"); | ||
InputStream is = connection.getInputStream(); | ||
String downloadedString = IOUtils.toString(is, StandardCharsets.UTF_8); | ||
return downloadedString; | ||
} | ||
|
||
/** | ||
* Method to download as a byte array | ||
* | ||
* @param url | ||
* the url to download form | ||
* @return the byte array of the downloaded content | ||
* @throws IOException | ||
* occures on errors during download | ||
*/ | ||
public static byte[] downloadAsByteArray(URL url) throws IOException { | ||
URLConnection connection = url.openConnection(); | ||
connection.setRequestProperty("User-Agent", | ||
"Mozilla/5.0 Gecko/20100316 Firefox/3.6.2"); | ||
InputStream is = connection.getInputStream(); | ||
byte[] downloadedBytes = IOUtils.toByteArray(is, is.available()); | ||
return downloadedBytes; | ||
} | ||
|
||
} |