也就是以下过程的逆过程:
public String selfReadFile(String strFileName){
StringBuffer buf=null;
BufferedReader breader = null;//reader for the template files
try
{
breader = new BufferedReader(new InputStreamReader(new FileInputStream((strFileName)),Charset.forName("utf-8")));
buf = new StringBuffer();
while(breader.ready())
buf.append((char)breader.read());
breader.close();
}//try
catch(Exception e)
{
e.printStackTrace();
}//catch
return buf.toString();
}
public String selfReadFile(String strFileName){
StringBuffer buf=null;
BufferedReader breader = null;//reader for the template files
try
{
breader = new BufferedReader(new InputStreamReader(new FileInputStream((strFileName)),Charset.forName("utf-8")));
buf = new StringBuffer();
while(breader.ready())
buf.append((char)breader.read());
breader.close();
}//try
catch(Exception e)
{
e.printStackTrace();
}//catch
return buf.toString();
}
解决方案 »
- android屏幕只能横屏,不能竖屏
- android wifi porting到平板UI时发生错误
- 求助:java.lang.NoClassdefFoundError:org.apache.cxf.jaxws.JaxWsProxyFactoryBean错误
- 能否不让用户安装任何软件,仅连计算机就实现通讯录备份啊?
- 求各位大哥帮我分析一下这个需求(Android)
- 请问关于添加jar包得问题
- 帅哥美女们速度进来看看啊
- 请教eclipse如何查看NullPointerException所在行数?
- Android不同activity之间的跳转问题
- 我为程序写了一个异常处理类,有下面问题
- 请教关于添加应用程序的问题
- 求助:ListView怎么显示不了,Adapter实现是否有问题...哪位帮忙看下...
BufferedReader br=null;
try {
is=asset.open("airport.txt");
br=new BufferedReader(new InputStreamReader(is,"GBK"));
fos=new FileOutputStream("/data/data/com.tarena.android/airport_1.txt");
String str=null;
while((str=br.readLine())!=null){
fos.write(str.getBytes());
fos.flush();
}catch (IOException e) {
// TODO: handle exception
}finally{
if(br!=null)try{br.close();}catch(IOException e){}
if(is!=null)try{is.close();}catch(IOException e){}
if(fos!=null)try{fos.close();}catch(IOException e){}
}