diff --git a/brouter-codec/src/main/java/btools/codec/MicroCache2.java b/brouter-codec/src/main/java/btools/codec/MicroCache2.java index 8cd8f30..16223a1 100644 --- a/brouter-codec/src/main/java/btools/codec/MicroCache2.java +++ b/brouter-codec/src/main/java/btools/codec/MicroCache2.java @@ -15,7 +15,7 @@ public final class MicroCache2 extends MicroCache private int latBase; private int cellsize; - public MicroCache2( int size, byte[] databuffer, int lonIdx, int latIdx, int divisor ) throws Exception + public MicroCache2( int size, byte[] databuffer, int lonIdx, int latIdx, int divisor ) { super( databuffer ); // sets ab=databuffer, aboffset=0 @@ -34,7 +34,7 @@ public final class MicroCache2 extends MicroCache return b; } - public MicroCache2( StatCoderContext bc, DataBuffers dataBuffers, int lonIdx, int latIdx, int divisor, TagValueValidator wayValidator, WaypointMatcher waypointMatcher ) throws Exception + public MicroCache2( StatCoderContext bc, DataBuffers dataBuffers, int lonIdx, int latIdx, int divisor, TagValueValidator wayValidator, WaypointMatcher waypointMatcher ) { super( null ); cellsize = 1000000 / divisor; diff --git a/brouter-mapaccess/src/main/java/btools/mapaccess/Rd5DiffManager.java b/brouter-mapaccess/src/main/java/btools/mapaccess/Rd5DiffManager.java index 86ff392..3b33904 100644 --- a/brouter-mapaccess/src/main/java/btools/mapaccess/Rd5DiffManager.java +++ b/brouter-mapaccess/src/main/java/btools/mapaccess/Rd5DiffManager.java @@ -8,8 +8,10 @@ package btools.mapaccess; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; +import java.io.IOException; import java.security.DigestInputStream; import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; final public class Rd5DiffManager { @@ -93,30 +95,31 @@ final public class Rd5DiffManager } } - public static String getMD5( File f ) throws Exception + public static String getMD5( File f ) throws IOException { - MessageDigest md = MessageDigest.getInstance("MD5"); - BufferedInputStream bis = new BufferedInputStream( new FileInputStream( f ) ); - DigestInputStream dis = new DigestInputStream(bis, md); - byte[] buf = new byte[8192]; - for(;;) - { - int len = dis.read( buf ); - if ( len <= 0 ) - { - break; + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + BufferedInputStream bis = new BufferedInputStream(new FileInputStream(f)); + DigestInputStream dis = new DigestInputStream(bis, md); + byte[] buf = new byte[8192]; + for (; ; ) { + int len = dis.read(buf); + if (len <= 0) { + break; + } } - } - dis.close(); - byte[] bytes = md.digest(); + dis.close(); + byte[] bytes = md.digest(); - StringBuilder sb = new StringBuilder(); - for (int j = 0; j < bytes.length; j++) - { - int v = bytes[j] & 0xff; - sb.append( hexChar( v >>> 4 ) ).append( hexChar( v & 0xf ) ); + StringBuilder sb = new StringBuilder(); + for (int j = 0; j < bytes.length; j++) { + int v = bytes[j] & 0xff; + sb.append(hexChar(v >>> 4)).append(hexChar(v & 0xf)); + } + return sb.toString(); + } catch (NoSuchAlgorithmException e) { + throw new IOException("MD5 algorithm not available", e); } - return sb.toString(); } private static char hexChar( int v ) diff --git a/brouter-mapaccess/src/main/java/btools/mapaccess/Rd5DiffTool.java b/brouter-mapaccess/src/main/java/btools/mapaccess/Rd5DiffTool.java index ac2f1d9..e1e48c6 100644 --- a/brouter-mapaccess/src/main/java/btools/mapaccess/Rd5DiffTool.java +++ b/brouter-mapaccess/src/main/java/btools/mapaccess/Rd5DiffTool.java @@ -12,6 +12,7 @@ import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.IOException; import java.util.Arrays; import btools.codec.DataBuffers; @@ -60,7 +61,7 @@ final public class Rd5DiffTool implements ProgressListener return false; } - private static long[] readFileIndex( DataInputStream dis, DataOutputStream dos ) throws Exception + private static long[] readFileIndex( DataInputStream dis, DataOutputStream dos ) throws IOException { long[] fileIndex = new long[25]; for( int i=0; i<25; i++ ) @@ -85,7 +86,7 @@ final public class Rd5DiffTool implements ProgressListener return index[tileIndex]; } - private static int[] readPosIndex( DataInputStream dis, DataOutputStream dos ) throws Exception + private static int[] readPosIndex( DataInputStream dis, DataOutputStream dos ) throws IOException { int[] posIndex = new int[1024]; for( int i=0; i<1024; i++ ) @@ -105,7 +106,7 @@ final public class Rd5DiffTool implements ProgressListener return idx == -1 ? 4096 : posIdx[idx]; } - private static byte[] createMicroCache( int[] posIdx, int tileIdx, DataInputStream dis, boolean deltaMode ) throws Exception + private static byte[] createMicroCache( int[] posIdx, int tileIdx, DataInputStream dis, boolean deltaMode ) throws IOException { if ( posIdx == null ) { @@ -125,7 +126,7 @@ final public class Rd5DiffTool implements ProgressListener return ab; } - private static MicroCache createMicroCache( byte[] ab, DataBuffers dataBuffers ) throws Exception + private static MicroCache createMicroCache( byte[] ab, DataBuffers dataBuffers ) { if ( ab == null || ab.length == 0 ) { @@ -286,7 +287,7 @@ final public class Rd5DiffTool implements ProgressListener } - public static void recoverFromDelta( File f1, File f2, File outFile, ProgressListener progress /* , File cmpFile */ ) throws Exception + public static void recoverFromDelta( File f1, File f2, File outFile, ProgressListener progress /* , File cmpFile */ ) throws IOException { if ( f2.length() == 0L ) { @@ -468,7 +469,7 @@ final public class Rd5DiffTool implements ProgressListener } } - public static void copyFile( File f1, File outFile, ProgressListener progress ) throws Exception + public static void copyFile( File f1, File outFile, ProgressListener progress ) throws IOException { boolean canceled = false; DataInputStream dis1 = new DataInputStream( new BufferedInputStream( new FileInputStream( f1 ) ) ); @@ -756,7 +757,7 @@ final public class Rd5DiffTool implements ProgressListener this.dataBuffers = dataBuffers; } - public MicroCache readMC() throws Exception + public MicroCache readMC() throws IOException { if (skips < 0 ) { @@ -775,7 +776,7 @@ final public class Rd5DiffTool implements ProgressListener return mc; } - public void finish() throws Exception + public void finish() { skips = -1; }