Here you can find the source of toInputStream(String[] stringArray)
public static InputStream toInputStream(String[] stringArray)
//package com.java2s; /**/*from ww w. j a v a2 s . c o m*/ * Copyright 2000-2009 DFKI GmbH. * All Rights Reserved. Use is subject to license terms. * * This file is part of MARY TTS. * * MARY TTS 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, version 3 of the License. * * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. * */ import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.UnsupportedEncodingException; public class Main { public static InputStream toInputStream(String str) { ByteArrayInputStream stream = null; try { stream = new ByteArrayInputStream(str.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return stream; } public static InputStream toInputStream(String[] stringArray) { return toInputStream(stringArray, 0); } public static InputStream toInputStream(String[] stringArray, int startIndex) { return toInputStream(stringArray, startIndex, stringArray.length); } public static InputStream toInputStream(String[] stringArray, int startIndex, int endIndex) { String str = toString(stringArray, startIndex, endIndex); return toInputStream(str); } /** * Combine the elements of the given string array into a single string, containing one array element per line. * * @param stringArray * stringArray * @return toString(stringArray, 0) */ public static String toString(String[] stringArray) { return toString(stringArray, 0); } /** * Combine the elements of the given string array into a single string, containing one array element per line. * * @param stringArray * stringArray * @param startIndex * startIndex * @return toString(stringArray, startIndex, stringArray.length - 1) */ public static String toString(String[] stringArray, int startIndex) { return toString(stringArray, startIndex, stringArray.length - 1); } /** * Combine the elements of the given string array into a single string, containing one array element per line. * * @param stringArray * stringArray * @param startIndex * startIndex * @param endIndex * endIndex * @return str converted to string */ public static String toString(String[] stringArray, int startIndex, int endIndex) { if (startIndex < 0) startIndex = 0; if (startIndex > stringArray.length - 1) startIndex = stringArray.length - 1; if (endIndex < startIndex) endIndex = startIndex; if (endIndex > stringArray.length - 1) endIndex = stringArray.length - 1; StringBuilder str = new StringBuilder(); for (int i = startIndex; i <= endIndex; i++) { str.append(stringArray[i]).append(System.getProperty("line.separator")); } return str.toString(); } public static String toString(double[][] array) { String str = ""; int i, j; for (i = 0; i < array.length; i++) { for (j = 0; j < array[i].length; j++) { str += String.valueOf(array[i][j]); if (j < array[i].length - 1) str += " "; } str += System.getProperty("line.separator"); } str += System.getProperty("line.separator"); return str; } }