-2
我已經創建了一個記事本圖書庫,看起來像這樣後到來:字後按字母順序排序字符串數組列表 t【JAVA]
Author | Name of the book | Availability? | Readers Code | Return Date
----------------------------------------------------------------------------
J. K. Rowling Harry Potter Yes - -
Mark Sullivan The Black Book Yes - -
Margaret Atwood Rogue Yes - -
,我需要用的書按字母名稱進行排序這一點。 單詞使用\ t分隔。 我該怎麼做?
This is the code that adds new books :
try (BufferedWriter bw = new BufferedWriter(
new FileWriter("C:/Users/Name/Desktop/library.txt", true))) {
System.out.print("Enter authors name\t");
name = sc.nextLine();
name = sc.nextLine();
author[l] = name;
System.out.print("Enter books name\t");
name = sc.nextLine();
bookname[l] = name;
vaiBib[l] = "Yes";
BilNr[l] = "-";
AtgDat[l] = "-";
l++;
if ((author[l- 1] != null) && (bookname[l- 1] != null)) {
content = bookname[l- 1] + "\t\t" + author[l- 1] + "\t\t" + vaiBib[l- 1]
+ "\t\t\t" + BilNr[l- 1] + "\t\t" + AtgDat[l- 1];
bw.write(content);
bw.newLine();
}
} catch (IOException e) {
e.printStackTrace();
}
而與此代碼我做鏈表從線是在記事本中:
BufferedReader br = new BufferedReader(new FileReader("C:/Users/Name/Desktop/library.txt"));
ArrayList<String> Line2= new ArrayList<>();
while ((line = br.readLine()) != null) {
Line2.add(line);
}
你能通過添加代碼來幫助我們並編輯你的文章嗎? – CodingNinja
這使得它更容易回答。但**請發佈最小的必要代碼!! ** – CodingNinja