關於集合,IO流的練習

2021-08-20 05:20:30 字數 1043 閱讀 1133

1.鍵盤錄入5個學生資訊(姓名,語文成績,數學成績,英語成績),按照總分從高到低存入文字檔案

public class test1 

});//建立學生物件並鍵盤錄入資訊

for(int i=1;i<=2;i++)

bufferedwriter bw = new bufferedwriter(new filewriter("students.txt"));

bw.newline();

bw.flush();

bw.write("姓名,語文成績,數學成績,英語成績");

bw.newline();

bw.flush();

//遍歷集合,將集合中的資料寫入文字檔案

for (student s : ts)

}}

public class student

public student(string name, int cinese, int math, int english)

public string getname()

public void setname(string name)

public int getcinese()

public void setcinese(int cinese)

public int getmath()

public void setmath(int math)

public int getenglish()

public void setenglish(int english)

@override

public string tostring()

}

2.已知s.txt檔案中有這樣的乙個字串:「hcexfgijkamdnoqrzstuvwybpl」

請編寫程式讀取資料內容,把資料排序後寫入ss.txt中。

public class test2 

}

IO流的練習

定義學生類,包含姓名 string name 性別 string gender 年齡 int age 三個屬性,生成空參有參構造,set和get方法,tostring方法 2.鍵盤錄入6個學員資訊 錄入格式 張三,男,25 要求有兩個相同的資訊,將6個學員資訊存入到arraylist集合中 3.將存...

IO流的練習

學生名單乙份學生作業若干份,分別儲存在 作業 資料夾中 在 作業統計結果.txt 中沒有交作業的學生名字後邊新增 未交作業 已提交的名字後邊新增 已提交 1 使用bufferedreader 讀取原始名單並以 張三 未交作業 存入hashmap 中 2 使用file.list 方法獲取提交作業資料夾...

IO流練習 一

一 明確資料來源和目的 源 輸入流,inputstream reader 目的 輸出流,outputstream writer 二 操作的資料是否為純文字 純文字 字元流 非純文字 位元組流 三 當明確體系後,再明確要使用哪個具體的物件 通過裝置來區分 源裝置 記憶體 硬碟 鍵盤 目的裝置 記憶體 ...