Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个看起来像这样的字符串:
"foobar\n"
我使用 BufferedReader 读取了这个字符串。我需要能够检测是否存在新行。我正在使用 readLine,但我切换到阅读,所以我可以抓住 \n 但没有运气。
我试过这个并且它有效:
while((charT = reader.read()) != -1) { if(charT != '\n') System.out.println("Carriage Return!"); }