Hello all, I am trying to send file across network using ObjectInputStream() and ObjectOutputStream().

My File class is Serializable which is this:
package Unicorn.UnicornUtilities ;
 
import java.io.* ;
 
public class Attachment implements Serializable{
	public String fileName = null ;
	public String fileExt = null ;
	long fileSize = 0 ;
	byte [] fileContents ;
 
	public Attachment (File f){
		try{
			fileName = new String(f.getName()) ;
			fileSize = f.length() ;
			fileExt = fileName.substring(fileName.indexOf(".") + 1) ;
			fileContents = new byte[(int)fileSize] ;
			InputStream fIn = new FileInputStream(f) ;
			fIn.read(fileContents, 0, (int)(fileSize - 1)) ; 
			fIn.close() ;
		} catch (Exception e){
		}
 
 
	}
	public void fileFlush(File f){
		try{
			OutputStream fOut = new FileOutputStream(f) ;
			fOut.write(fileContents, 0, (int)(fileSize - 1)) ;
			fOut.flush() ;
			fOut.close() ;
		} catch (Exception e){
 
		}
	}
}

I send from client side like this:
out.writeObject(new Attachment(new File(fPath))) ; // fPath is just a valid String
out.flush() ;

And in the server side i do this to write file to disk:
Attachment att = (Attachment)in.readObject() ;
att.fileFlush(new File(att.fileName)) ;

While this is working perfectly fine with WinXP, under Windows 7 the file seems to be corrupted. Texts are ok, but pdf, jpg, mp3 aren't. Can some1 point out plz what i am doing wrong ?? Thanx in advance. Would be very greatful.