Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-236

Add "Read" Methods With Size Limits to FileUtils

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.0
    • Fix Version/s: 3.x
    • Component/s: Utilities
    • Labels:
      None
    • Environment:

      1.4+

      Description

      I suggest adding versions of the utility methods for reading lines and Strings from a file that also accept a limit on the number of bytes or lines that should be read. I propose that the following methods be added:

      String readFileToString(File file, long byteCountToRead)
      String readFileToString(File file, String encoding, long byteCountToRead)
      byte[] readFileToByteArray(File file, long byteCountToRead)
      byte[] readFileToByteArray(File file, String encoding, long byteCountToRead)
      List<String> readLines(File file, long lineCountToRead)
      List<String> readLines(File file, String encoding, long lineCountToRead)

      One of the drawbacks I have encountered to using the methods in the past is that I only needed to read a limited number of bytes or lines from a file and I had to read the entire file. This can be especially dangerous if run on a file that is quite large, and only a portion of the file is needed.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                mwooten.dev Michael Wooten
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Time Tracking

                  Estimated:
                  Original Estimate - 6h
                  6h
                  Remaining:
                  Remaining Estimate - 6h
                  6h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified