📄 songcollection.java
字号:
package com.fugle.model;
import java.awt.*;
//import java.lang.*;
//import java.io.IOException;
import java.io.*;
public class SongCollection
{
/**
* @param args
*/
/* //数组方法实现
public static Song[] song = new Song[10];
public static void getCollection1() throws IOException
{
//读取文件
FileReader fr = new FileReader("MySongs.txt");
BufferedReader br = new BufferedReader(fr);
String line = br.readLine();
int i = 0;
//while(line != null)
{
//int i = 0;
//for(int j = 0 ; j < 4; j++)
{
song[0].name = "q";
//song[i].setName(line);
//song[i].name = line;
//song[i].singer = line;
//song[i].style = line;
//song[i].publishdate = line;
//line = br.readLine();
}
i++;
}
br.close();
fr.close();
System.out.println(song[0].name);
}
*/
//List方法实现
public static List lstname = new List();
public static List lstsinger = new List();
public static List lststyle = new List();
public static List lstpublishdate = new List();
public static void getCollection2() throws IOException
{
//lst.add(Song song0);
FileReader fr = new FileReader("MySongs.txt");
BufferedReader br = new BufferedReader(fr);
String line = br.readLine();
while(line != null)
{
lstname.add(line);
lstsinger.add(br.readLine());
lststyle.add(br.readLine());
lstpublishdate.add(br.readLine());
line = br.readLine();
}
br.close();
fr.close();
/*
for(int i = 0 ; i < lstname.getItemCount() ; i++)
{
//System.out.println(lstname.getItemCount());
System.out.println(lstname.getItem(i));
System.out.println(lstsinger.getItem(i));
System.out.println(lststyle.getItem(i));
System.out.println(lstpublishdate.getItem(i));
System.out.println();
}
*/
}
public static void main(String[] args) throws IOException
{
//SongCollection.getCollection1();
//SongCollection.getCollection2();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -