All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.fornwall.jelf.ElfStringTable Maven / Gradle / Ivy

There is a newer version: 0.9.8
Show newest version
package net.fornwall.jelf;


import java.io.ByteArrayOutputStream;
import java.nio.ByteBuffer;

final class ElfStringTable {

	/** The string table data. */
	private final ByteBuffer buffer;

	/** Reads all the strings from [offset, length]. */
	ElfStringTable(ElfParser parser, long offset, int length) throws ElfException {
		parser.seek(offset);
		buffer = parser.readBuffer(length);
	}

	private final ByteArrayOutputStream baos = new ByteArrayOutputStream(16);

	String get(int index) {
		buffer.position(index);
		baos.reset();
		byte b;
		while((b = buffer.get()) != 0) {
			baos.write(b);
		}
		return baos.toString();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy