安卓输入流转String
2017-03-16 18:43
85 查看
安卓输入流转String:
package utils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
/*
*
*/
public class StreamUtils {
/*
*/
public static String readFromStream(InputStream in) throws IOException{
ByteArrayOutputStream out=new ByteArrayOutputStream();
int len=0;
byte[] buffer=new byte[1024];
while((len=in.read(buffer))!=-1){
out.write(buffer,0,len);
}
}
本人个人项目地址:百度搜索安卓应用—-点击进入百度应用市场—搜索”电话老人版”
package utils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
/*
*
*/
public class StreamUtils {
/*
*/
public static String readFromStream(InputStream in) throws IOException{
ByteArrayOutputStream out=new ByteArrayOutputStream();
int len=0;
byte[] buffer=new byte[1024];
while((len=in.read(buffer))!=-1){
out.write(buffer,0,len);
} String result = out.toString(); in.close(); out.close(); return result;
}
}
本人个人项目地址:百度搜索安卓应用—-点击进入百度应用市场—搜索”电话老人版”
相关文章推荐
- android 随手记 -输入流转成String
- Flex - 带时间选择(可手工输入)的日期组件,去掉了 StringToolkit.formatNumberWithChar
- 安卓入门:动态输入日期与时间
- String类型变量转成InputStream或者Reader流类型,用于sax解析的输入,转成InputStream时中文乱码,转成Reader流就好了
- 安卓EditText限制输入类型的一些技巧
- 安卓基本控件使用:EditText的光标的使用(模拟拨号界面的输入)
- Android string.xml如何输入空格、换行等符号——转义字符
- 编写一个小程序,从标准输入读入一系列string对象,寻找连续重复出现的单词。程序应该找出满足一下条件的单词:该单词的后面紧接着再次出现自己本身。跟踪重复次数最多的单词及其重复次数,输出.
- c++输入带有空格的string
- 程序运行时提示输入一个整数并利用Scanner类接收数据,输出该数值是几位数。(要求:利用String 类中的方法)
- 安卓学习杂记——关于should use @string resource警告的消除
- 安卓简单开发-Edittext限制输入文本
- 8.9 编写函数打开文件用于输入,将文件内容读入 string 类型的 vector 容器,每一行存储为该容器对象 的一个元素。8.10 重写上面的程序,把文件中的每个单词存储为 容器的一个元素
- OutputDebugString实现变参输入
- Textarea输入字数限制(兼容iOS&安卓)
- 在mysql命令行中输入字符串提示 Incorrect string value: '\xC4\xE3' for column 'name' 出现异常
- 输入输出string
- Jackson怎样转换这样的字符串? String jsonStr = "{dataType:'Custom',regexp:'t\\d+',msg:'输入不正确'}";
- 安卓实现支付宝6位密码输入界面
- 关于ios端与安卓端使用input 限制只能输入数字