Java String from List stringsAsBytes(List strs)

Here you can find the source of stringsAsBytes(List strs)

Description

Convert strings to byte arrays.

License

Open Source License

Parameter

Parameter Description
strs some strings.

Return

a list of bytes in each string

Declaration

public static List<byte[]> stringsAsBytes(List<String> strs) 

Method Source Code

//package com.java2s;
/*************************************************************************************************
 * Java binding of Tokyo Cabinet/*from w w w .j a  v a 2s  .  c o m*/
 *                                                               Copyright (C) 2006-2010 FAL Labs
 * This file is part of Tokyo Cabinet.
 * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of
 * the GNU Lesser General Public License as published by the Free Software Foundation; either
 * version 2.1 of the License or any later version.  Tokyo Cabinet 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 Lesser General Public
 * License for more details.
 * You should have received a copy of the GNU Lesser General Public License along with Tokyo
 * Cabinet; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307 USA.
 *************************************************************************************************/

import java.util.*;

public class Main {
    /**
     * Convert strings to byte arrays.
     * @param strs some strings.
     * @return a list of bytes in each string
     */
    public static List<byte[]> stringsAsBytes(List<String> strs) {
        if (strs == null)
            strs = Collections.emptyList();
        List<byte[]> skeys = new ArrayList<byte[]>(strs.size());
        for (String s : strs) {
            skeys.add(s.getBytes());
        }
        return skeys;
    }
}

Related

  1. stringListToString(List list)
  2. stringListToString(List list, String delim)
  3. stringListToString(List ls)
  4. stringListToString(List stringList, String delim)
  5. stringListToString(List strList, String delim)
  6. stringToMatriz(List linhas)