Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4255280

URL.getContent() loses first six bytes for ftp URLs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.2
    • core-libs
    • beta
    • generic
    • generic



      Name: rlT66838 Date: 07/19/99


      The following code leaves out the first six bytes of the file:

      ----

      import java.net.*;
      import java.io.*;
      import java.util.*;

      public class bug {

          public static void main(String[] args) {
            String url = "ftp://jet.corp.fedex.com/pub/jet/release/Manifest";
            try {
                int totalBytes = 0;
                URL location = new URL(url);
                InputStream stream = (InputStream)location.getContent();
                byte[] buffer = new byte[1024];
                int bytesRead = stream.read(buffer);
                while (bytesRead != -1) {
                    totalBytes += bytesRead;
                    bytesRead = stream.read(buffer);
                }
                System.err.println(totalBytes + " bytes downloaded");
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.exit(0);
          }

      }
      (Review ID: 85774)
      ======================================================================

            jccollet Jean-Christophe Collet (Inactive)
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: