Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Syntax error on token "void", @ expected

805731Oct 15 2010 — edited Oct 15 2010
Hi,

Could someone help me out here? I get a "Syntax error on token "void", @ expected" error in eclipse under the "void" syntax. Also, I get a bunch of errors on "Syntax error on tokens, delete these tokens" ... below is the code.

import java.io.IOException;

public static void main(String[] args) throws NoSuchAlgorithmException, FileNotFoundException
{
MessageDigest digest = MessageDigest.getInstance("MD5");
File f = new File("c:\\myfile.txt");
InputStream is = new FileInputStream(f);
byte[] buffer = new byte[8192];
int read = 0;
try {
while( (read = is.read(buffer)) > 0) {
digest.update(buffer, 0, read);
}
byte[] md5sum = digest.digest();
BigInteger bigInt = new BigInteger(1, md5sum);
String output = bigInt.toString(16);
System.out.println("MD5: " + output);
}
catch(IOException e) {
throw new RuntimeException("Unable to process file for MD5", e);
}
finally {
try {
is.close();
}
catch(IOException e) {
throw new RuntimeException("Unable to close input stream for MD5 calculation", e);
}
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 12 2010
Added on Oct 15 2010
1 comment
3,903 views