small fixes

This commit is contained in:
nazar-kutz 2021-03-01 13:24:30 +02:00
parent cea1fa60e7
commit fa353ad87c
2 changed files with 6 additions and 11 deletions

View file

@ -565,16 +565,11 @@ public class Algorithms {
}
}
public static ByteArrayInputStream createByteArrayIS(InputStream inputStream) throws IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
int i = 0;
while ((i = inputStream.read()) != -1) {
outputStream.write(i);
}
inputStream.close();
byte[] byteArray = outputStream.toByteArray();
return new ByteArrayInputStream(byteArray);
public static ByteArrayInputStream createByteArrayIS(InputStream in) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
streamCopy(in, out);
in.close();
return new ByteArrayInputStream(out.toByteArray());
}
@SuppressWarnings("ResultOfMethodCallIgnored")

View file

@ -95,7 +95,7 @@ public class GpxEngine extends OnlineRoutingEngine {
}
private GPXFile parseGpx(@NonNull String content) {
InputStream gpxStream = null;
InputStream gpxStream;
try {
gpxStream = new ByteArrayInputStream(content.getBytes("UTF-8"));
return GPXUtilities.loadGPXFile(gpxStream);