import java.io.*;public class test3{
public static void makeFile( StringBuffer sb, String path ){
String str = sb.toString();
String name = str.substring( 0, 80 ).trim();
String content = str.substring( 80 );
String filePath = path;
File myFilePath = new File( filePath );
if( !myFilePath.exists() ){
myFilePath.mkdirs();
System.out.println( "mkdir() " );
}
File myFile = new File( filePath, name );
try{
BufferedWriter bw = new BufferedWriter( new FileWriter( myFile ) );
bw.write( content );
bw.close();
}catch( IOException ioe ){
System.out.println( "Wrong ........." );
}
}
public static void main( String[] args ){
StringBuffer sb = new StringBuffer();
sb.append( " " );
sb.append( " 3fg.txt" );
sb.append( " " );
sb.append( " " );
sb.append( " " );
sb.append( " " );
sb.append( " " );
sb.append( " " );
sb.append( "wouieoeoeo" );
String path = "d:" + File.separator + "abc" + File.separator + "efg";
System.out.println( path );
test3.makeFile( sb, path );
}
}我测试过了
你可以测试一下看看如何
有问题再说
public static void makeFile( StringBuffer sb, String path ){
String str = sb.toString();
String name = str.substring( 0, 80 ).trim();
String content = str.substring( 80 );
String filePath = path;
File myFilePath = new File( filePath );
if( !myFilePath.exists() ){
myFilePath.mkdirs();
System.out.println( "mkdir() " );
}
File myFile = new File( filePath, name );
try{
BufferedWriter bw = new BufferedWriter( new FileWriter( myFile ) );
bw.write( content );
bw.close();
}catch( IOException ioe ){
System.out.println( "Wrong ........." );
}
}
public static void main( String[] args ){
StringBuffer sb = new StringBuffer();
sb.append( " " );
sb.append( " 3fg.txt" );
sb.append( " " );
sb.append( " " );
sb.append( " " );
sb.append( " " );
sb.append( " " );
sb.append( " " );
sb.append( "wouieoeoeo" );
String path = "d:" + File.separator + "abc" + File.separator + "efg";
System.out.println( path );
test3.makeFile( sb, path );
}
}我测试过了
你可以测试一下看看如何
有问题再说
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货