无法从 ReadLine (bufferedReader) 存储值
Not being able to store value from ReadLine (bufferedReader)
所以我在使用 bufferedReader 中的 readLine() 方法保存值时遇到了问题,这是我的代码当前的样子:
in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
while((inputLine=in.readLine())!= null)
try { g.doc.insertString(g.doc.getLength(), "\n" + new Xmlgetter(inputLine).outString, g.style);
}
catch (BadLocationException e){
e.printStackTrace();
}
我想实现的是能够两次使用inputLine的值。我 运行 遇到的问题是,无论我如何尝试保存它,我都会调用 in.readLine(),第二次调用时它是空的。想法?
将读取的值存储到一个变量中,并在需要时随时重用它。
使用通常的模式:
variable = readValue;
while (variable != null) {
// use the variable value any times
variable = readNextValue;
}
所以我在使用 bufferedReader 中的 readLine() 方法保存值时遇到了问题,这是我的代码当前的样子:
in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
while((inputLine=in.readLine())!= null)
try { g.doc.insertString(g.doc.getLength(), "\n" + new Xmlgetter(inputLine).outString, g.style);
}
catch (BadLocationException e){
e.printStackTrace();
}
我想实现的是能够两次使用inputLine的值。我 运行 遇到的问题是,无论我如何尝试保存它,我都会调用 in.readLine(),第二次调用时它是空的。想法?
将读取的值存储到一个变量中,并在需要时随时重用它。
使用通常的模式:
variable = readValue;
while (variable != null) {
// use the variable value any times
variable = readNextValue;
}