Issue #45 Unicode character cannot save

Code formatting
This commit is contained in:
Jindra Petk
2013-03-30 16:43:26 +01:00
parent d3bd9b641d
commit be106cc34b
772 changed files with 84378 additions and 84353 deletions

View File

@@ -26,59 +26,59 @@ import java.io.InputStream;
*/
public class ReReadableInputStream extends InputStream {
InputStream is;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] converted;
int pos = 0;
int count = 0;
InputStream is;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] converted;
int pos = 0;
int count = 0;
public int getCount() {
return count;
}
public int getCount() {
return count;
}
public byte[] getAllRead() {
return baos.toByteArray();
}
public byte[] getAllRead() {
return baos.toByteArray();
}
public int getPos() {
return pos;
}
public int getPos() {
return pos;
}
public ReReadableInputStream(InputStream is) {
this.is = is;
}
public ReReadableInputStream(InputStream is) {
this.is = is;
}
public void setPos(int pos) throws IOException {
if (pos > count) {
this.pos = count;
skip(pos - count);
}
this.pos = pos;
}
public void setPos(int pos) throws IOException {
if (pos > count) {
this.pos = count;
skip(pos - count);
}
this.pos = pos;
}
@Override
public int read() throws IOException {
if (pos < count) {
if (converted == null) {
converted = baos.toByteArray();
}
int ret = converted[pos] & 0xff;
pos++;
return ret;
}
int i = is.read();
if (i > -1) {
baos.write(i);
count++;
}
pos++;
converted = null;
@Override
public int read() throws IOException {
if (pos < count) {
if (converted == null) {
converted = baos.toByteArray();
}
int ret = converted[pos] & 0xff;
pos++;
return ret;
}
int i = is.read();
if (i > -1) {
baos.write(i);
count++;
}
pos++;
converted = null;
return i;
}
return i;
}
@Override
public int available() throws IOException {
return (count + is.available()) - pos;
}
@Override
public int available() throws IOException {
return (count + is.available()) - pos;
}
}