public int Close()
   {
     int retcode = DDC_SUCCESS;
   
      switch ( fmode )
      {
   	  	case RFM_WRITE:
	  	  try
		  {
			file.seek(0);
	  	    try
			{
				byte[] br = new byte[8];
				br[0] = (byte) ((riff_header.ckID >>> 24) & 0x000000FF);
				br[1] = (byte) ((riff_header.ckID >>> 16) & 0x000000FF);
				br[2] = (byte) ((riff_header.ckID >>> 8) & 0x000000FF);
				br[3] = (byte) (riff_header.ckID & 0x000000FF);
			    
				br[7] = (byte) ((riff_header.ckSize >>> 24)& 0x000000FF);
				br[6] = (byte) ((riff_header.ckSize >>> 16)& 0x000000FF);
				br[5] = (byte) ((riff_header.ckSize >>> 8)& 0x000000FF);
				br[4] = (byte) (riff_header.ckSize & 0x000000FF);
				file.write(br,0,8);	
				file.close();
			} catch (IOException ioe)
			    {
				   retcode = DDC_FILE_ERROR;
				}
		  } catch (IOException ioe)
		    {
			   retcode = DDC_FILE_ERROR;
			}
   		   break;
   
   	  	case RFM_READ:
   	  	   try
		   {
   		        file.close();
   		   } catch (IOException ioe)
		    {
			   retcode = DDC_FILE_ERROR;
			}
   		   break;
      }
      file = null;   
      fmode = RFM_UNKNOWN;
   	  return retcode;
   }