将数组列表写入文本文件 [英] Writing arraylist to textfile
本文介绍了将数组列表写入文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 Room
类的数组列表,它保存在 Hostel
类中,我想将此数组列表写入文本文件.这样做的最有效方法是什么?
I have an arraylist of class Room
which is held in class Hostel
, i would like to write this arraylist to a text file. What is the most efficient method of doing so?
宿舍类
public class Hostel
{
private ArrayList < Room > rooms;
}
房间等级
abstract class Room
{
public Room(int newRoomNo, boolean newRoomEnSuite, int newRoomNights, String newRoomBooker)
{
roomNo = newRoomNo;
roomEnSuite = newRoomEnSuite;
roomBooking = "Booked";
roomNights = newRoomNights;
roomBooker = newRoomBooker;
}
}
推荐答案
来自 commons-io
FileUtils.writeLines(new File(path), list);
这篇关于将数组列表写入文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文