Home  >  Q&A  >  body text

java - Ask a question about IO

OutputStream outputStream = uploadFileUtil.getTargetFileOutputStream(monthlyReportFolder, fileName);

I use a method to return the stream object of the SmbFile object based on the Http file path, that is, I obtain the OutputStream. It is known that this file is an html file. Now I want to read this file into a String object, that is, I want to get the source code in this html file.
Please tell me how to operate,

我想大声告诉你我想大声告诉你2685 days ago551

reply all(1)I'll reply

  • 習慣沉默

    習慣沉默2017-05-17 10:08:43

    What is the specific instance type pointed to by this outputStream?
    Assuming it points to a FileOutputStream, you can use code similar to the following to obtain its source code.

    OutputStream outputStream = new FileOutputStream(fileName);
    ByteArrayOutputStream baos=new ByteArrayOutputStream();  
    outputStream.write(baos.toByteArray());  
    str = baos.toString(); 

    reply
    0
  • Cancelreply