试试看:byte[] br={13,10};(不知道13,10是不是要反一反)
写好后:myfile.write(br);
不一定行,不过可以试试

解决方案 »

  1.   

    FileOutputStream myfile=new FileOutputStream("log/"+filename);
    for(int i = 0; i< 数据集数量;i++)
          {
                table_name = 从数据库中取的值
                strBuff.append(System.getProperty("line.separator"));//add this
                myfile.write(strBuff.getBytes("GB2312"));
           }
    myfile.close();
      

  2.   

    myfile.write(new String("aaa \n").getBytes());
      

  3.   

    1.myfile.write(strBuff.getBytes("GB2312"));//strBuff没有getBytes方法
    2.在写字符串到文件的时候加个\n看看//这个方法我试过也不可以
      

  4.   

    笨办法:write(13)//回车
            write(10)//换行
    省事的办法:用PrintWriter的println方法
      

  5.   

    import java.sql.*;
    import java.util.*;
    import java.io.*;
    public class WriterTxt {public static void main(String[]args){
    ResultSet rs = null ;try{
    Class.forName("oracle.jdbc.driver.OracleDriver");String url="jdbc:oracle:thin:@localhost:1521:ora8";
    Connection conn= DriverManager.getConnection(url,"","");
    Statement stmt = conn.createStatement();
    String sqlstr = "select name,handfee,homefee from t_mi_pefeetab a "; 
    rs = stmt.executeQuery(sqlstr);  BufferedWriter out = new BufferedWriter(new FileWriter(new File("test.txt")));  ResultSetMetaData rsmd=rs.getMetaData();
      int fields=rsmd.getColumnCount(); 
      rs=stmt.executeQuery(sqlstr);
      while(rs.next()){
    line_str=",";
    for(i=1;i<=fields;i++)
    {
    String sColName = rs.getString(i);
    sColName = sColName + line_str;
    sColName = sColName + "\r\n"; 
    out.write(sColName);
    }
    out.newLine();
      }
      out.close();
      System.out.println("文件已成功导出!");  stmt.close();
      conn.close();
    }
    catch(Exception es){
    es.printStackTrace();
    }
    }
    }
      

  6.   

    使用FileOutputStream和PrintWriter就可以了啊!FileOutputStream fos = new FileOutputStream("c:/xxxx.txt");
    PrintWriter pw = new PrintWriter(fos, true);pw.println("ddddddddddddddddddddd");即可!JerKii