Created
August 6, 2014 17:33
-
-
Save dilnei/e8f5333c81f5d30da6ca to your computer and use it in GitHub Desktop.
Transforma uma String para um InputStream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package br.com.risingforce.converters; | |
| import java.io.ByteArrayInputStream; | |
| import java.io.File; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| /** | |
| * <b>Transforma uma String para um InputStream.</b> | |
| * | |
| * @author Dilnei Cunha. | |
| */ | |
| public class StringToInputStream { | |
| /** | |
| * <b>Método responsável por transformar uma String em um Stream de | |
| * dados.</b> | |
| * | |
| * @param str | |
| * @return InputStream | |
| */ | |
| public InputStream inputStreamStr(String str) { | |
| return new ByteArrayInputStream(str.getBytes()); | |
| } | |
| /** | |
| * <b>Método responsável por transformar um File em um Stream de dados.</b> | |
| * | |
| * @param str | |
| * @return InputStream | |
| */ | |
| public InputStream inputStreamStr(File fileStr) throws IOException { | |
| return new ByteArrayInputStream(FileToString.readFileAsString(fileStr.getAbsolutePath()).getBytes()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment