回覆列表
  • 1 # 使用者993555227987

    1.可以這樣定義你的ArrayListArrayList<String> list = new ArrayList<String>();

    2.現在不清楚你的text內容是怎麼樣的,現在假設你的text內容獲取後是一個String型別的值,並透過list.add()方法加入ArrayList容器中。

    3.現在介紹ArrayList的元素輸出OutputStream fOut = null; try { fOut = new FileOutputStream(new File("D:/test.txt")); } catch (FileNotFoundException e) { e.printStackTrace(); } for(String Str:list){ try { fOut.write((Str+"\n").getBytes()); } catch (IOException e) { e.printStackTrace(); } } if(fOut != null){ try { fOut.close(); } catch (IOException e) {e.printStackTrace(); }如果有問題,可以私聊我,或者在QQ上或者微信上與我一塊探討,謝謝!

  • 中秋節和大豐收的關聯?
  • 如何分辨手機cpu的好壞?