我正在阅读一个.txt
文件,并希望在将结果放入StringBuilder
.
文本示例:
以下 Bicycle 类是自行车的一种可能实现:
/* 自行车类 class Bicycle {
int 节奏 = 0;
整数速度 = 0; } */
所以这就是我可以得出的结论:
public class Main {
public static BufferedReader in;
public static StringBuilder stringBuilder = new StringBuilder();
public static void main(String[] args) {
String input = "input_text.txt";
try {
in = new BufferedReader(new FileReader(input));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
String inputText;
try {
while ((inputText = in.readLine()) != null) {
if (inputText.startsWith("/*")) {
// The problem is there:
while (!inputText.endsWith("*/")) {
int lengthLine = inputText.length();
in.skip((long)lengthLine);
}
}
stringBuilder.append(inputText);
}
} catch (IOException e) {
e.printStackTrace();
}
我得到了无限while循环,无法跳到下一行。
杨__羊羊
相关分类