package ATM;
//信1705-3 20173517 赵家明
public class Account {
private String accountID;
private String accountname;
private String operatedate;
private int operatetype;
private String accountpassword;
private int accountbalance;
private int amount;
Account ()
{
accountID="20173517";
accountname="zjm";
operatedate="2018-09-20";
operatetype=1;
accountpassword="042669";
accountbalance=1000;
amount=100;
}
Account (String a,String b,String c,int d,String e,int f,int g)
{
accountID=a;
accountname=b;
operatedate=c;
operatetype=d;
accountpassword=e;
accountbalance=f;
amount=g;
}
public void set_accountID(String str)
{
accountID=str;
}
public void set_accountname(String str)
{
accountname=str;
}
public void set_operatedate(String str)
{
operatedate=str;
}
public void set_operatetype(int n)
{
operatetype=n;
}
public void set_accountpassword(String str)
{
accountpassword=str;
}
public void set_accountbalance(int n)
{
accountbalance=n;
}
public void set_amount(int n)
{
amount=n;
}
public String get_accountID()
{
return accountID;
}
public String get_accountname()
{
return accountname;
}
public String get_operatedate()
{
return operatedate;
}
public int get_operatetype()
{
return operatetype;
}
public String get_accountpassword()
{
return accountpassword;
}
public int get_accountbalance()
{
return accountbalance;
}
public int get_amount()
{
return amount;
}
}
package ATM;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.RandomAccessFile;
@SuppressWarnings("unused")
public class FileOperation {
//创建文件
public static boolean createFile(File fileName)throws Exception{
@SuppressWarnings("unused")
Boolean flag=false;
try{
if(!fileName.exists()){
fileName.createNewFile();
flag=true;
}
}
catch(Exception e){
e.printStackTrace();
}
return true;
}
//读TXT文件内容
public static String readTxtFile(File fileName)throws Exception{
String result=null;
FileReader fileReader=null;
BufferedReader bufferedReader=null;
try{
fileReader=new FileReader(fileName);
bufferedReader=new BufferedReader(fileReader);
try{
String read=null;
while((read=bufferedReader.readLine())!=null){
result=result+read+"\r\n";
}
}
catch(Exception e){
e.printStackTrace();
}
}
catch(Exception e){
e.printStackTrace();
}
finally{
if(bufferedReader!=null){
bufferedReader.close();
}
if(fileReader!=null){
fileReader.close();
}
}
System.out.println("读取出来的文件内容是:"+"\r\n"+result);
return result;
}
public static void contentToTxt(String filePath, String content) {
String str = new String(); //原有txt内容
String s1 = new String();//内容更新
try {
File f = new File(filePath);
if (f.exists()) {
System.out.print("文件存在");
} else {
System.out.print("文件不存在");
f.createNewFile();// 不存在则创建
}
BufferedReader input = new BufferedReader(new FileReader(f));
while ((str = input.readLine()) != null) {
s1 += str + "\n";
}
System.out.println(s1);
input.close();
s1 += content;
BufferedWriter output = new BufferedWriter(new FileWriter(f));
output.write(s1);
output.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
问题:
1.Java语言不熟练,不能迅速编写
2.文件导入出现问题
3.总会忘掉实例化
4.不够专注,不能静心
最后日常催眠,热爱Java!