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

Files.readAllBytes is not supported

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 7
    • core-libs

      FULL PRODUCT VERSION :
      xcelys@linux-2ld93h1:~/test> java -version
      java version " 1.7.0-ea "
      Java(TM) SE Runtime Environment (build 1.7.0-ea-b104)
      Java HotSpot(TM) 64-Bit Server VM (build 19.0-b05, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Desktop -- openSUSE 11.4 - 2.6.37.6-24

      A DESCRIPTION OF THE PROBLEM :
      testReadAllBytes.java:14: cannot find symbol
      String strErr = new String(Files.readAllBytes(Paths.get(path)));

      produces systax error on linux, but not on windows.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      package test;

      import java.nio.file.Files;
      import java.nio.file.Paths;

      public class testReadAllBytes {

      /**
       * @param args
       */
      public static void main(String[] args) {

      String path = " /home/xcelys/test/testReadAllBytess.java " ;
      String strErr = new String(Files.readAllBytes(Paths.get(path)));
      System.out.println(strErr);

      }

      }


      javac testReadAllBytes.java


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Clean compile
      ACTUAL -
      error message

      1 error
      xcelys@linux-2ld93h1:~/test> ./test.sh
      testReadAllBytes.java:14: cannot find symbol
      String strErr = new String(Files.readAllBytes(Paths.get(path)));
                                      ^
        symbol: method readAllBytes(Path)
        location: class Files
      1 error




      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      1 error
      xcelys@linux-2ld93h1:~/test> ./test.sh
      testReadAllBytes.java:14: cannot find symbol
      String strErr = new String(Files.readAllBytes(Paths.get(path)));
                                      ^
        symbol: method readAllBytes(Path)
        location: class Files
      1 error


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package test;

      import java.nio.file.Files;
      import java.nio.file.Paths;

      public class testReadAllBytes {

      /**
       * @param args
       */
      public static void main(String[] args) {

      String path = " /home/xcelys/test/testReadAllBytess.java " ;
      String strErr = new String(Files.readAllBytes(Paths.get(path)));
      System.out.println(strErr);

      }

      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None found.

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: