如果只有一行数据或下一行为空,我将如何结束do while循环?

    BufferedReader in = new BufferedReader(new InputStreamReader(is));
    String inputLine = "";

    try {
        do {
            JSONData += inputLine;
        }
     }
        while ((inputLine = in.readLine()) != null);
    }

最佳答案

您可以使用,

while ((inputLine = in.readLine()) != null && !inputLine.isEmpty());

09-26 10:02