java 读txt中文乱码
publicvoidreadyFile(){StringstrFile="";FileReaderin=null;try{StringstrLine="";in=newF...
public void readyFile(){
String strFile="";
FileReader in=null;
try{
String strLine="";
in=new FileReader(getPath);
buf=new BufferedReader(in);
strLine=buf.readLine();
while(strLine!=null){
strFile+=strLine;
strLine=buf.readLine();
}
}catch(IOException e1){
e1.printStackTrace();
}
strbFile=new StringBuffer(strFile);
fileOver=false;
}
public void readFile(){
String strPart=""; int n=320;
if(strbFile.length()<=n){
jta1.setText(strbFile+"\n");
fileOver=true;
return;
}
strPart=strbFile.substring(0,n);
strbFile=strbFile.delete(0,n);
jta1.setText(strPart+"\n");
} 展开
String strFile="";
FileReader in=null;
try{
String strLine="";
in=new FileReader(getPath);
buf=new BufferedReader(in);
strLine=buf.readLine();
while(strLine!=null){
strFile+=strLine;
strLine=buf.readLine();
}
}catch(IOException e1){
e1.printStackTrace();
}
strbFile=new StringBuffer(strFile);
fileOver=false;
}
public void readFile(){
String strPart=""; int n=320;
if(strbFile.length()<=n){
jta1.setText(strbFile+"\n");
fileOver=true;
return;
}
strPart=strbFile.substring(0,n);
strbFile=strbFile.delete(0,n);
jta1.setText(strPart+"\n");
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询