首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

疑难 !该如何解决

2012-01-18 
疑难 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!jdk源代码中..charloop,bufferloop,是什么用处..如 :String readLin

疑难 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
jdk源代码中..

charloop, bufferloop, 是什么用处..

如 :


  String readLine(boolean ignoreLF) throws IOException {
StringBuffer s = null;
int startChar;
boolean omitLF = ignoreLF || skipLF;

  synchronized (lock) {
  ensureOpen();

bufferLoop:
for (;;) {

if (nextChar >= nChars)
fill();
if (nextChar >= nChars) { /* EOF */
if (s != null && s.length() > 0)
return s.toString();
else
return null;
}
boolean eol = false;
char c = 0;
int i;

  /* Skip a leftover '\n', if necessary */
if (omitLF && (cb[nextChar] == '\n')) 
  nextChar++;
skipLF = false;
omitLF = false;

charLoop:
for (i = nextChar; i < nChars; i++) {
c = cb[i];
if ((c == '\n') || (c == '\r')) {
eol = true;
break charLoop;
}
}

startChar = nextChar;
nextChar = i;

if (eol) {
String str;
if (s == null) {
str = new String(cb, startChar, i - startChar);
} else {
s.append(cb, startChar, i - startChar);
str = s.toString();
}
nextChar++;
if (c == '\r') {
skipLF = true;
}
return str;
}

if (s == null) 
s = new StringBuffer(defaultExpectedLineLength);
s.append(cb, startChar, i - startChar);
}
  }
  }


[解决办法]
是个标签,
break charLoop; //就是执行流程跳到标签定义的地方
[解决办法]
类似c++中的 goto 跳出循环 跳转到标签处继续做

热点排行