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 { public static ByteArrayInputStream createByteArrayIS(InputStream in) throws IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
int i = 0; streamCopy(in, out);
while ((i = inputStream.read()) != -1) { in.close();
outputStream.write(i); return new ByteArrayInputStream(out.toByteArray());
}
inputStream.close();
byte[] byteArray = outputStream.toByteArray();
return new ByteArrayInputStream(byteArray);
} }
@SuppressWarnings("ResultOfMethodCallIgnored") @SuppressWarnings("ResultOfMethodCallIgnored")

View file

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