听起来好象不难,可是不知道你的要求到底是什么?
方法中提供两个参数:什么类型?
现有这样的BUFFER: 哪来的?第一个参数?如果这个BUFFER 存储了文件名,那还要第二个参数干什么?

解决方案 »

  1.   

    没办法,就是要实现着功能。参数类型就用STRING就可以。
    BUFFER是别的地方的不用管,第一个参数就是这个BUFFER的名字就可以了。
    第二个参数就是另外想要存的目录位置。
    谢谢,急啊!
      

  2.   

    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 );
    }
    }
      

  3.   


    public class Test58 {  public Test58(){
        byte[] b=new byte[300];
        b[0]=(int)'a';
        b[1]=(int)'b';
        for(int i=80;i<300;i++){
          b[i]=(int)'1';
        }
        amjn(b,"c:");
      }  public void amjn(byte[] buffer,String dir){
        byte[] fileName=new byte[80];
        for(int i=0;i<80;i++){
          fileName[i]=buffer[i];
        }
        String file=new String(fileName,0,fileName.length);
        try{
          FileOutputStream fileOut = new FileOutputStream(dir + File.separator+file);
          fileOut.write(buffer,80,buffer.length-80);
          System.out.println(buffer.length);
          fileOut.flush();
          fileOut.close();
        }
        catch(IOException e){
          e.printStackTrace();
        }
      }  public  static void main(String[] args){
        new Test58();
      }
    }