Project

General

Profile

« Previous | Next » 

Revision 654

Added by berkley over 23 years ago

fixed error in logic. sending the filesize as an int terminated by a zero failed when the file size was greater than 256. The filesize is now sent as a string followed by a zero.

View differences:

DataStreamTest.java
98 98
      
99 99
      //write the length of the file followed by a 0
100 100
      long flength = file.length();
101
      //System.out.println("file sized (B): " + flength);
102
      dsout.write((int)flength);
101
      System.out.println("file sized (B): " + flength);
102
      String sflength = String.valueOf(flength);
103
      
104
      byte[] fl = sflength.getBytes();
105
      for(int i=0; i<fl.length; i++)
106
      {
107
        dsout.write(fl[i]);
108
      }
103 109
      dsout.write(0);
110
      
111
      //dsout.write((int)flength);
112
      //dsout.write(0);
104 113
      dsout.flush();
105 114
      
106 115
      // now read response from server
......
114 123
      while (cnt!=-1) 
115 124
      {
116 125
        cnt = fs.read(buf);
117
        //System.out.println("i = "+ i +" Bytes read = " + cnt);
126
        System.out.println("i = "+ i +" Bytes read = " + cnt);
118 127
        if (cnt!=-1) 
119 128
        {
120 129
          dsout.write(buf, 0, cnt);

Also available in: Unified diff