可以說,在一個文件中的線路有:如何檢查是否一行是空白的,如果有,跳過它,使用掃描儀的Java
代碼:
String string = input.nextLine();
int index=0;
System.out.println(string);
if(string.contains(" "))
{
while(string.contains(" "))
{
int random = string.indexOf(" ");
String temp6 = string.substring(index,random);
ps.print(pig(temp6)+" ");
int temp8 = temp6.length();
String temp7 = string.substring(temp8+1,string.length());
string=temp7;
}
ps.print(pig(string));
}
else
{
ps.println(pig(string));
//}
}
對於輸入:
Hello
Bob
我怎麼會讓掃描儀跳過後你好? 或者我如何刪除空行?
你現在怎樣掃描線條?你知道如何檢查'String'是否爲空? –
發佈你的unskiped代碼 – newuser
你讀過'String'類的javadoc嗎? –