如何在 java 中处理多行 textarea 字符串。这里是我的字符串示例:
eg 1:
!1234 //here after !1234 there is some white space
ADFGKLJUYGHH
eg 2:
!123455//here after!1234555 there is no space
ASDFGERTYUJDCVBNMFGH
我知道在从文件读取时如何处理这些字符串,但现在我已经从 JTextArea 读取并为这些读取的字符串执行了一些功能。(这里我们应该只考虑字符串的第二行,第一行应该被忽略)
怎么做?
从文件或控制台读取的代码是:
line=br.readLine();
while (line!=null)
{
if (line.length() != 0 && line.charAt(0) == '>')
{
String name = line.trim();
System.out.println(name);
StringBuffer sb = new StringBuffer();
line = br.readLine();
while(line!=null &&line.length()==0)
{
line = br.readLine();
}
while (line!=null &&line.charAt(0) != '>')
{
sb.append(line);
if (line!=null)
{
line = br.readLine();
}
else
{
break;
}
}
String ss = sb.toString();
operation(seq,name,fnew,num);
}
else
{
line = br.readLine();
}
}
// br.close();
// bufferFileWriter.close();
}