<commit_before>/*
 * Java core library component.
 *
 * Copyright (c) 1997, 1998
 *      Transvirtual Technologies, Inc.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file.
 */

package java.io;

import kaffe.util.UTF8;

public class DataInputStream extends FilterInputStream implements DataInput {

public DataInputStream(InputStream in) {
	super(in);
}

public final int read(byte b[]) throws IOException {
	return read(b, 0, b.length);
}

public final int read(byte b[], int off, int len) throws IOException {
	return super.read(b, off, len);
}

public final boolean readBoolean() throws IOException {
	return (readUnsignedByte() != 0);
}

public final byte readByte() throws IOException {
	int value = read();
	if (value == -1) {
		throw new EOFException();
	}
	return ((byte)value);
}

public final char readChar() throws IOException {
	int val = read() << 8;
	val |= read();
	if (val == -1) {
		throw new EOFException();
	}
	return ((char)val);
}

public final double readDouble() throws IOException {
	return Double.longBitsToDouble(readLong());
}

public final float readFloat() throws IOException {
	return Float.intBitsToFloat(readInt());
}

public final void readFully(byte b[]) throws IOException {
	readFully(b, 0, b.length);    
}

public final void readFully(byte b[], int off, int len) throws IOException {
	if (b == null) {
		throw new NullPointerException();
	}
	int total = 0;
	while (total < len) {
		int got = read(b, off + total, len - total);
		if (got == -1) {
			throw new EOFException();
		}
		total += got;
	}
}

public final int readInt() throws IOException {
	int v1 = read() << 24;
	v1 |= read() << 16;
	v1 |= read() << 8;
	int v2 = read();
	if (v2 == -1) {
		throw new EOFException();
	}
	return (v1 | v2);
}

/**
 * @deprecated
 */
public final String readLine() throws IOException {
	final StringBuffer buffer = new StringBuffer();
	final byte[] data = new byte[1];
	boolean eof = false;

	while (true) {
		if (read(data, 0, 1) != 1) {
			eof = true;
			break;
		}
		final char ch = (char) (data[0] & 0xff);
		if (ch == '\n') {
			break;
		}

		if (ch == '\r') {       // Check for '\r\n'
			// Note that we don't know whether the InputStream
			// implements mark() and reset(), but we're using
			// them anyway. If they don't, then characters
			// after a lone '\r' will be elided from the input
			// (ie, this is a bug). We could override mark()
			// and reset() to always provide at least a
			// one-character buffer, but then we'd violate
			// the spec, which says to inherit these from
			// FilterInputStream...

			super.mark(1);
			if (read(data, 0, 1) == 1 && data[0] != '\n') {
				try {
					super.reset();
				}
				catch (IOException e) {
				}
			}
			break;
		}
		buffer.append(ch);
	}
	if (eof == true && buffer.length() == 0) {
		return (null);
	}
	return (buffer.toString());
}

public final long readLong() throws IOException {
	return ((long)readInt() << 32) | ((long)readInt() & 0xffffffffL);
}

public final short readShort() throws IOException {
	int val = read() << 8;
	val |= read();
	if (val == -1) {
		throw new EOFException();
	}
	return ((short)val);
}

public final String readUTF() throws IOException {
	return UTF8.decode(this, readUnsignedShort());
}

public final int readUnsignedByte() throws IOException {
	return readByte() & 0xff;
}

public final int readUnsignedShort() throws IOException {
	return readShort() & 0xffff;
}

public final int skipBytes(int n) throws IOException {
	int remain = n;
	while (remain > 0) {
		remain -= (int)in.skip((long)remain);
	}
	return n;
}
}<commit_msg>Add missing method: readUTF(DataInput in)<commit_after>/*
 * Java core library component.
 *
 * Copyright (c) 1997, 1998
 *      Transvirtual Technologies, Inc.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file.
 */

package java.io;

import kaffe.util.UTF8;

public class DataInputStream extends FilterInputStream implements DataInput {

public DataInputStream(InputStream in) {
	super(in);
}

public final int read(byte b[]) throws IOException {
	return read(b, 0, b.length);
}

public final int read(byte b[], int off, int len) throws IOException {
	return super.read(b, off, len);
}

public final boolean readBoolean() throws IOException {
	return (readUnsignedByte() != 0);
}

public final byte readByte() throws IOException {
	int value = read();
	if (value == -1) {
		throw new EOFException();
	}
	return ((byte)value);
}

public final char readChar() throws IOException {
	int val = read() << 8;
	val |= read();
	if (val == -1) {
		throw new EOFException();
	}
	return ((char)val);
}

public final double readDouble() throws IOException {
	return Double.longBitsToDouble(readLong());
}

public final float readFloat() throws IOException {
	return Float.intBitsToFloat(readInt());
}

public final void readFully(byte b[]) throws IOException {
	readFully(b, 0, b.length);    
}

public final void readFully(byte b[], int off, int len) throws IOException {
	if (b == null) {
		throw new NullPointerException();
	}
	int total = 0;
	while (total < len) {
		int got = read(b, off + total, len - total);
		if (got == -1) {
			throw new EOFException();
		}
		total += got;
	}
}

public final int readInt() throws IOException {
	int v1 = read() << 24;
	v1 |= read() << 16;
	v1 |= read() << 8;
	int v2 = read();
	if (v2 == -1) {
		throw new EOFException();
	}
	return (v1 | v2);
}

/**
 * @deprecated
 */
public final String readLine() throws IOException {
	final StringBuffer buffer = new StringBuffer();
	final byte[] data = new byte[1];
	boolean eof = false;

	while (true) {
		if (read(data, 0, 1) != 1) {
			eof = true;
			break;
		}
		final char ch = (char) (data[0] & 0xff);
		if (ch == '\n') {
			break;
		}

		if (ch == '\r') {       // Check for '\r\n'
			// Note that we don't know whether the InputStream
			// implements mark() and reset(), but we're using
			// them anyway. If they don't, then characters
			// after a lone '\r' will be elided from the input
			// (ie, this is a bug). We could override mark()
			// and reset() to always provide at least a
			// one-character buffer, but then we'd violate
			// the spec, which says to inherit these from
			// FilterInputStream...

			super.mark(1);
			if (read(data, 0, 1) == 1 && data[0] != '\n') {
				try {
					super.reset();
				}
				catch (IOException e) {
				}
			}
			break;
		}
		buffer.append(ch);
	}
	if (eof == true && buffer.length() == 0) {
		return (null);
	}
	return (buffer.toString());
}

public final long readLong() throws IOException {
	return ((long)readInt() << 32) | ((long)readInt() & 0xffffffffL);
}

public final short readShort() throws IOException {
	int val = read() << 8;
	val |= read();
	if (val == -1) {
		throw new EOFException();
	}
	return ((short)val);
}

public final String readUTF() throws IOException {
	return UTF8.decode(this, readUnsignedShort());
}

public static final String readUTF(DataInput in) throws IOException {
	return UTF8.decode(in, in.readUnsignedShort());
}

public final int readUnsignedByte() throws IOException {
	return readByte() & 0xff;
}

public final int readUnsignedShort() throws IOException {
	return readShort() & 0xffff;
}

public final int skipBytes(int n) throws IOException {
	int remain = n;
	while (remain > 0) {
		remain -= (int)in.skip((long)remain);
	}
	return n;
}
}
{'fraction_non_alphanumeric': 0.14445643377394118, 'fraction_numerical': 0.013892635554356622, 'mean_word_length': 3.4136904761904763, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2132104', 'n_tokens_mistral': 2651, 'n_tokens_neox': 2419, 'n_words': 847}