くだすれJava(超初心 ..
969:デフォルトの名無しさん
08/06/06 00:39:55
>>966
がんばってかいたよ!!!うごかしてみてね!!!
import java.io.*;
public class Sample {
public static void main(String[] args) throws IOException {
String text = String.format("あんこ1%n" + "あんこ2%n" + "%n" +
"あんこ3%n" + "あんこ4%n" + "%n" + "%n" +
"あんこ5%n" + "あんこ6%n" + "%n" + "あんこ7%n");
PushbackReader r = new PushbackReader(new StringReader(text));
StringBuilder buf = new StringBuilder();
int c;
while ((c = r.read()) != -1) {
if (c == 12354) {
c += 60;
} else if (c == 10) {
int cnt = 0;
int next;
while ((next = r.read()) != -1 && next == 10) {
++cnt;
}
if (cnt < 2) c += 12279;
r.unread(next);
}
buf.append(Character.toChars(c));
}
String result = buf.toString();
System.out.println(result);
}
}
970:デフォルトの名無しさん
08/06/06 00:47:50
ちょっとスレの趣旨とは違うかもしれない質問だけど、
Java の Servlet API の話題を取り上げてるスレって
ないの?
971:957
08/06/06 03:23:56
>>969
12line c += 60; は、削除するとして。
read(EOF) の戻り値が 65535 (になった)なので、==の左辺を(short)でキャスト
または、-1を(char)でキャストするといいよ。vv
最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
4024日前に更新/302 KB
担当:undef