public static int getStr() throws Exception{
String filename="E:\\aa\\abc.txt";
String filename2="E:\\aa\\abcd.txt";
File file=new File(filename);
File file2=new File(filename2);
FileInputStream fis=new FileInputStream(file);
FileOutputStream fos=new FileOutputStream(file2);
int num;
byte[] by=new byte[(int) file.length()];//加入此代码可解决产生空格问题
// byte[] by=new byte[1024];//有可能产生空格
while((num=fis.read(by))!=-1){
fos.write(by);
}
fis.close();
fos.close();
String str=new String(by,"UTF-8");
System.out.println(str);
System.out.println(str.length());
return 0;
}