Here you can find the source of readFlashString(DataInputStream s)
public static String readFlashString(DataInputStream s) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.DataInputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; public class Main { public static CharsetDecoder stringDecoder = Charset.forName("UTF-8").newDecoder(); public static String readFlashString(DataInputStream s) throws IOException { // Get the length. int len = s.readUnsignedShort(); if (len == 0) return null; byte[] bytes = new byte[len]; for (int i = 0; i < len; i++) bytes[i] = s.readByte();//w ww . j a v a 2 s . c o m return stringDecoder.decode(ByteBuffer.wrap(bytes)).toString(); } }