Java String Decode decodeStrings(byte[] stringBytes)

Here you can find the source of decodeStrings(byte[] stringBytes)

Description

decode Strings

License

Open Source License

Declaration

public static String[] decodeStrings(byte[] stringBytes) 

Method Source Code

//package com.java2s;
/* // www .  j ava 2s. c  o  m
   Java MFS (jmfs) - Copyright (C) 2010 Artem Erchov
   Contact: comer0@gmail.com 
    
   This file is part of jmfs.
    
   jmfs is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
    
   jmfs is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
    
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

public class Main {
    public static String[] decodeStrings(byte[] stringBytes) {
        return decodeStrings(stringBytes, 0, (stringBytes == null) ? 0 : stringBytes.length);
    }

    public static String[] decodeStrings(byte[] stringBytes, int off, int len) {
        String result = null;
        try {
            result = new String(stringBytes, off, len, "ASCII");
        } catch (java.io.UnsupportedEncodingException e) {
            result = new String(stringBytes, off, len);
        }
        return (result == null) ? null : result.trim().split("\0"); /*.replace("\0", ""); */
    }
}

Related

  1. decodeString(String s, String encoding)
  2. decodeString(String str)
  3. decodeString(String str)
  4. decodeString(StringReader in)
  5. decodeStringFromByteArray(byte[] data)
  6. decodeText(String encodeText)
  7. decodeText(String s)
  8. decodeText(String str)
  9. decodeTextQuietly(String input)