@Override
	public void write(File file) throws IOException {
		FileOutputStream fout = new FileOutputStream(file);
		DataOutputStream dout = new DataOutputStream(fout);
		
		//check if charFrequencies should be stored as a byte, short, or int
		byte dataType = 0;
		for(int i : charFrequencies) {
			if(i > Short.MAX_VALUE)
				dataType = 2;
			else if(i > Byte.MAX_VALUE)
				dataType = 1;
		}
		
		dout.writeByte(dataType);
		
		dout.writeInt(stringLength);
		dout.writeInt(numZeroes);
		for(int i : charFrequencies) {
			if(dataType == 0)
				dout.writeByte(i);
			else if(dataType == 1)
				dout.writeShort(i);
			else if(dataType == 2)
				dout.writeShort(i);
		}
		dout.write(encodedMessage.toByteArray());
		
	}