【发布时间】:2016-05-28 21:56:11
【问题描述】:
如何使用 Retrofit 甚至更好的 Rx Retrofit 下载和读取文本文件?
以下是改造时间之前的示例。 真的是如何在 Retrofit 中转换下面的代码 示例:
try {
// Create a URL for the desired page
URL url = new URL("ksite.com/thefile.txt");
// Read all the text returned by the server
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String str;
while ((str = in.readLine()) != null) {
// str is one line of text; readLine() strips the newline character(s)
}
in.close();
} catch (MalformedURLException e) {
} catch (IOException e) {
}
非常感谢您的帮助。谢谢
【问题讨论】:
标签: java android http retrofit rx-java