0
如何在Java中使用StringReader讀取字符串的末尾,我不知道字符串的長度是多少。使用StringReader讀取字符串的結尾
這是我多遠,到目前爲止得到:
public static boolean portForward(Device dev, int localPort, int remotePort)
{
boolean success = false;
AdbCommand adbCmd = Adb.formAdbCommand(dev, "forward", "tcp:" + localPort, "tcp:" + remotePort);
StringReader reader = new StringReader(executeAdbCommand(adbCmd));
try
{
if (/*This is what's missing :/ */)
{
success = true;
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "There was an error while retrieving the list of devices.\n" + ex + "\nPlease report this error to the developer/s.", "Error Retrieving Devices", JOptionPane.ERROR_MESSAGE);
} finally {
reader.close();
}
return success;
}
那麼你想用字符串做什麼?目前還不清楚你想要檢查的條件。 –
那麼,我只是想檢查它是否是空的。相當誠實。 – SimonC
StringReader或多或少與任何Reader相同,所以假裝這是一個文件,你會怎麼做你想要的? –