Java Text File Read by Charset readString(DataInput input, int length, Charset charset)

Here you can find the source of readString(DataInput input, int length, Charset charset)

Description

reads from current position.

License

Apache License

Parameter

Parameter Description
input the input
length the length to read
charset the charset to use

Return

the String

Declaration

public static String readString(DataInput input, int length, Charset charset) throws IOException 

Method Source Code


//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);
    }
}

Related

  1. readLines(String filePath, Charset charset)
  2. readLines(String path, Charset charset)
  3. readNextWord(BufferedInputStream in, Charset cs)
  4. readStreamAsString(final InputStream iStream, Charset iCharset)
  5. readStreamToString(InputStream stream, Charset encoding)
  6. readString(final InputStream in, final Charset charset)
  7. readString(final InputStream in, final Charset charset)
  8. readString(final InputStream input, final Charset charset)
  9. readString(InputStream in, int numBytes, Charset encoding)