how to get url html contents to string in java

后端 未结 5 1870
北恋
北恋 2021-02-04 17:49

I have a html file stored on the server. I have the URL path something like this:

I want to rea

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-04 17:58

    Simplest way in my opinion is to use IOUtils

    import com.amazonaws.util.IOUtils;
    ...
    
    String uri = "https://localhost:9443/genesis/Receipt/Receipt.html";
    String fileContents = IOUtils.toString(new URL(uri).openStream());
    System.out.println(fileContents);
    

提交回复
热议问题