可能有N种吧, 看看io吧
    try {
      String s = "test1\r\ntest2";
      FileOutputStream out = new FileOutputStream("c:/test.txt");
      out.write(s.getBytes());
      out.close();
    }
    catch (IOException e) {
    }