如题:查数据库,返回结果遍历。保存到TXT文件当中,创建文件写完了,接下来有点懵,请高手解决下或者有相关的文章贴出来下,不胜感激。

解决方案 »

  1.   

    结果的保存的格式是什么? public static void saveResult(ResultSet set, String filePath) {
    PrintWriter out = null;
    try {
    out = new PrintWriter(filePath);
    while(set.next())
    {
    // String xxx = set.getString(columnLabel);  //TODO 自己写
    // String yyy = set.getString(columnLabel);  //TODO 自己写

    // out.println(xxx + yyy);
    out.flush();
    }
    } catch (IOException e) {
    e.printStackTrace();
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    if (out != null) {
    out.close();
    out = null;
    }
    }
    }放开注释,自己发挥....
      

  2.   

    不要求字符串,可以考虑。RandomAccessFile