巧了,我前不久刚好作了这样的一组程序,功能跟你说的差不多,你少作修改就可以用了。// SendFile.java
import java.io.*;
import java.net.*;
import java.text.*;public class SendFile
{
   public static void main( String args[] )
   {
      InetAddress IP;
      int Port;
      byte SendBuf[];
      Socket SendSock;
      long RstAt = 0;
      
      if ( args.length != 3 )
      {
         System.out.println( "Usage: SendFile IP port filename" );
         return;
      }
      
      try { // Convert the remote IP addreSendSock.
         IP = InetAddress.getByName( args[0] );
      }
      catch( UnknownHostException e )
      {
         System.out.println( "ERROR: Invalid IP address: "+e.getMessage() );
         return;
      }
      Port = (new Integer( args[1] )).intValue();  // Convert the UDP port.
      if ( (SendBuf = new byte[BUF_LENGTH]) == null )
      {
         System.out.println( "ERROR: can't create the send buffer." );
         return;
      }
      
      try {
         System.out.print( "Connecting to " + IP.getHostAddress() + " : " + Port );
         SendSock = new Socket( IP, Port );
         SendSock.setSoTimeout( SOCKET_TIMEOUT );
         OutputStream os = SendSock.getOutputStream();
         System.out.println( "\nOK ! " + SendSock.getInetAddress().getHostAddress() + " connected." );         System.out.println( "Opening file: " + args[2] );
         long FileLength = (new File( args[2] )).length() - RstAt;
         FileInputStream ifs = new FileInputStream( args[2] );
         ifs.skip( RstAt );         // Send the length of file.
         System.out.println( "File length: "+FileLength );
         SendBuf[0] = (byte)(FileLength & 0xff);
         SendBuf[1] = (byte)((FileLength >> 8) & 0xff);
         SendBuf[2] = (byte)((FileLength >> 16) & 0xff);
         SendBuf[3] = (byte)((FileLength >> 24) & 0xff);
         SendBuf[4] = (byte)((FileLength >> 32) & 0xff);
         SendBuf[5] = (byte)((FileLength >> 40) & 0xff);
         SendBuf[6] = (byte)((FileLength >> 48) & 0xff);
         SendBuf[7] = (byte)((FileLength >> 56) & 0xff);
         os.write( SendBuf, 0, 8 );
         
         // Send the restart point.
         System.out.println( "Restart at: "+RstAt);
         SendBuf[0] = (byte)(RstAt & 0xff);
         SendBuf[1] = (byte)((RstAt >> 8) & 0xff);
         SendBuf[2] = (byte)((RstAt >> 16) & 0xff);
         SendBuf[3] = (byte)((RstAt >> 24) & 0xff);
         SendBuf[4] = (byte)((RstAt >> 32) & 0xff);
         SendBuf[5] = (byte)((RstAt >> 40) & 0xff);
         SendBuf[6] = (byte)((RstAt >> 48) & 0xff);
         SendBuf[7] = (byte)((RstAt >> 56) & 0xff);
         os.write( SendBuf, 0, 8 );         System.out.println( "Transferring the file..." );
         int Count = 0;
         try {
            for( Count = 0; Count < (FileLength / BUF_LENGTH); Count ++ )
            {
               ifs.read( SendBuf, 0, BUF_LENGTH );
               os.write( SendBuf );
            }
            ifs.read( SendBuf, 0, (int)(FileLength - BUF_LENGTH * Count) );
            os.write( SendBuf, 0, (int)(FileLength - BUF_LENGTH * Count) );
         } catch( IOException e )
         {
            System.out.println( "ERROR: " + e.getMessage() );
            System.out.println( (Count*BUF_LENGTH) + " bytes finished." );
            return;
         }
         
         System.out.println( "Transfer OK !" );
      }
      catch( Exception e )
      {
         System.out.println( "ERROR: " + e.getMessage() );
         return;
      }
   }   static int BUF_LENGTH = 1024;
   static int SOCKET_TIMEOUT = 60000;
}
// RecvFile.java
import java.io.*;
import java.net.*;
import java.text.*;public class RecvFile
{
   public static void main( String args[] )
   {
      int Port;
      byte RecvBuf[];
      ServerSocket ConnectSock;
      long RstAt = 0;
      
      if ( args.length != 2 )
      {
         System.out.println( "Usage: RecvFile port filename" );
         return;
      }
      
      Port = (new Integer( args[0] )).intValue();  // Convert the UDP port.
      if ( (RecvBuf = new byte[BUF_LENGTH]) == null )
      {
         System.out.println( "ERROR: can't create the send buffer." );
         return;
      }
      
      try {
         System.out.print( "Waiting connection at port: " + Port );
         ConnectSock = new ServerSocket( Port );
         ConnectSock.setSoTimeout( SOCKET_TIMEOUT );
         Socket RecvSock = ConnectSock.accept();
         RecvSock.setSoTimeout( SOCKET_TIMEOUT );
         InputStream is = RecvSock.getInputStream();
         System.out.println( "\nOK ! " + RecvSock.getInetAddress().getHostAddress() + " connected." );         System.out.println( "Creating file: " + args[1] );
         FileOutputStream ofs;
         
         // Receive the length of file.
         is.read( RecvBuf, 0, 8 );
         long FileLength = RecvBuf[0] & 0xff;
         FileLength += (RecvBuf[1] << 8) & 0xff00l;
         FileLength += (RecvBuf[2] << 16) & 0xff0000l;
         FileLength += (RecvBuf[3] << 24) & 0xff000000l;
         FileLength += (RecvBuf[4] << 32) & 0xff00000000l;
         FileLength += (RecvBuf[5] << 40) & 0xff0000000000l;
         FileLength += (RecvBuf[6] << 48) & 0xff000000000000l;
         FileLength += (RecvBuf[7] << 56) & 0xff00000000000000l;
         
         // Receive the restart point.
         is.read( RecvBuf, 0, 8 );
         RstAt = RecvBuf[0] & 0xff;
         RstAt += (RecvBuf[1] << 8) & 0xff00l;
         RstAt += (RecvBuf[2] << 16) & 0xff0000l;
         RstAt += (RecvBuf[3] << 24) & 0xff000000l;
         RstAt += (RecvBuf[4] << 32) & 0xff00000000l;
         RstAt += (RecvBuf[5] << 40) & 0xff0000000000l;
         RstAt += (RecvBuf[6] << 48) & 0xff000000000000l;
         RstAt += (RecvBuf[7] << 56) & 0xff00000000000000l;
         if ( RstAt == 0 )
            ofs = new FileOutputStream( args[1], false );
         else
            ofs = new FileOutputStream( args[1], true );         System.out.println( "Receiving the file for " + FileLength + " bytes ..." );
         System.out.println( "Restart at: "+RstAt );
         int Count = 0;
         try {
            for( Count = 0; Count < (FileLength / BUF_LENGTH); Count ++ )
            {
               is.read( RecvBuf, 0, BUF_LENGTH );
               ofs.write( RecvBuf, 0, BUF_LENGTH );
            }
            is.read( RecvBuf, 0, (int)(FileLength - BUF_LENGTH * Count) );
            ofs.write( RecvBuf, 0, (int)(FileLength - BUF_LENGTH * Count) );
         } catch( IOException e )
         {
            System.out.println( "ERROR: " + e.getMessage() );
            System.out.println( (Count*BUF_LENGTH) + " bytes finished." );
            return;
         }         System.out.println( "Transfer OK !" );
      }
      catch( Exception e )
      {
         System.out.println( "ERROR: " + e.getMessage() );
         return;
      }
   }   static int BUF_LENGTH = 1024;
   static int SOCKET_TIMEOUT = 60000;
}