下面的程序要输出一段字符到d盘下面的一个文件夹,输出之后发现字符串之间都有空格,这是为什么?如何去掉?谢谢
import java.io.*;
import java.nio.channels.*;
import java.nio.* ;public class for_buffer { public static void main(String[] args) {
// TODO Auto-generated method stub
File afile = new File("d://java/new.txt") ;
FileOutputStream outputfile = null ;
if(afile.exists()){
try{
outputfile = new FileOutputStream(afile) ;
}
catch(Exception e){
System.out.println("1") ;
}
FileChannel outputchannel = outputfile.getChannel() ;
ByteBuffer b1 = ByteBuffer.allocate(24) ;
CharBuffer c1 = b1.asCharBuffer() ;
c1.put("hello".toCharArray()) ;
try{
outputchannel.write(b1) ;
}
catch(Exception e){
System.out.println("2") ;
}
}
else{
System.out.println("no file") ;
}
}}