Here you can find the source of readString(DataInput input, int length, Charset charset)
Parameter | Description |
---|---|
input | the input |
length | the length to read |
charset | the charset to use |
public static String readString(DataInput input, int length, Charset charset) throws IOException
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.io.DataInput; import java.io.IOException; import java.nio.charset.Charset; public class Main { /**// w ww .j a va 2 s . c o m * reads from current position. * * @param input the input * @param length the length to read * @param charset the charset to use * @return the String */ public static String readString(DataInput input, int length, Charset charset) throws IOException { byte[] data = new byte[length]; input.readFully(data); return new String(data, charset); } }