Hello,
Your problem is that BufferedReader buffer fills it whenever it can. You can perhaps use a PushBackInputStream as follows:
Code:
byte[] buf = new byte[512]; / / For you to see the size
String chset1, chset2, string;
StringBuilder tx;
PushBackInputStream in;
int index;
tx = new StringBuilder();
do {
tx.append(string);
in.read(buf, 0, Buffer.size);
string = new String(buf chset1);
index = string.indexOf("\ n");
} while ( Index == -1);
index + +; / / This is to include \ n in the first charset
tx.append(string.substringing(0, Index));
/ / it gets late in the second table charset
in.unread(buf, index buf.size - Index);
string = new String(buf, index buf.size - Index, chset2);
tx.append(string);
/ / We read the rest in the second charset
while(in.available != 0) {
in.read(buf, 0, Buffer.size);
string = new String(buf chset2);
tx.append(string);
}
System.out.System.out.println(tx.toString());
Bookmarks