JAVA服务端多个文件合并传到客户端分解

来源:互联网 发布:数据结构与算法 入门 编辑:程序博客网 时间:2024/05/04 03:01
    If Not FileExists(fromFileName) Then Exit;
      Filestream:= TFilestream.Create(fromFileName,fmOpenRead);
    vSize := 1024;
    Filestream.Position := 0;
    count :=1;
    vStart := 0;
    
    vSize := Filestream.Read(vArray,vSize);
    for i :=0 to  vSize-1 do
    begin
      if count>5 then
        Break;
      str := Chr(vArray[i]);
      messageStr:=messageStr+str;
      if str='\' then
        count := count+1;


      Inc(vStart);
    end;


    total := PosCopy(messageStr,'\',1);
    head := PosCopy(messageStr,'\',2);
    state := PosCopy(messageStr,'\',3);
    Filestream.Position := vStart;


    for i:=4 to PosNum(messageStr,'\') do
    begin
      fileInfo := PosCopy(messageStr,'\',i);
      fileName := StrLeft(fileInfo,'-');
      fileName := destSrc+'\'+ fileName;
      filelen := StrToInt64(StrRight(fileInfo,'-'));
      outfile := TFileStream.Create(fileName, fmCreate);
      try
        outfile.CopyFrom(Filestream,filelen);
      finally
        outfile.Free;
      end;
    end;
    
  finally
    freeandnil(Filestream);
  end;
原创粉丝点击