Rd5Diff: Specify IOException instead of generic Exception
This commit is contained in:
parent
13f5ad0bcf
commit
0a8d4dd1f2
3 changed files with 34 additions and 30 deletions
|
@ -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;
|
||||
|
|
|
@ -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,17 +95,16 @@ final public class Rd5DiffManager
|
|||
}
|
||||
}
|
||||
|
||||
public static String getMD5( File f ) throws Exception
|
||||
public static String getMD5( File f ) throws IOException
|
||||
{
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
BufferedInputStream bis = new BufferedInputStream( new FileInputStream( f ) );
|
||||
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 )
|
||||
{
|
||||
for (; ; ) {
|
||||
int len = dis.read(buf);
|
||||
if (len <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -111,12 +112,14 @@ final public class Rd5DiffManager
|
|||
byte[] bytes = md.digest();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int j = 0; j < bytes.length; j++)
|
||||
{
|
||||
for (int j = 0; j < bytes.length; j++) {
|
||||
int v = bytes[j] & 0xff;
|
||||
sb.append( hexChar( v >>> 4 ) ).append( hexChar( v & 0xf ) );
|
||||
sb.append(hexChar(v >>> 4)).append(hexChar(v & 0xf));
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IOException("MD5 algorithm not available", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static char hexChar( int v )
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue