Code example for RandomAccessFile

Methods: closelengthread

0
	public static long getCRC32(String filename)
	{ 
		// Attempt to read the file from disk 
		try 
		{ 
			RandomAccessFile file = new RandomAccessFile(filename, "r");
			 
			// Convert the file to a buffer 
			byte[] buffer = new byte[(int)file.length()];
			file.read(buffer);
			 
			// Generate the CRC from the buffer 
			CRC32 crc = new CRC32();
			crc.update(buffer);
			file.close();
			// Return the generated CRC 
			return crc.getValue();
		} 
		catch(IOException e)
		{ 
Stop searching for code, let great code find you!  Add Codota to your java IDE