Append data into a file using Apache Commons I/O

前端 未结 7 1607
野的像风
野的像风 2020-12-09 14:48

The FileUtils.writeStringToFile(fileName, text) function of Apache Commons I/O overwrites previous text in a file. I would like to append data to my file. Is th

相关标签:
7条回答
  • 2020-12-09 15:50
    public static void writeStringToFile(File file,
                                         String data,
                                         boolean append)
                                  throws IOException
    
    
       Writes the toString() value of each item in a collection to the specified File line by line. The default VM encoding and the default line ending will be used.
    
    Parameters:
        file - the file to write to
        lines - the lines to write, null entries produce blank lines
        append - if true, then the lines will be added to the end of the file rather than overwriting 
    Throws:
        IOException - in case of an I/O error
    Since:
        Commons IO 2.1
    
    0 讨论(0)
提交回复
热议问题