私の問題はです。ファイルリーダーで顧客名を読み取る方法がわかりません。ファイルリーダーでtxtファイルの顧客名を読む
私は予約システムを作成しており、顧客が既に存在することを知る必要があります。だから私はCustomers.txtファイルを読んで、誰かがすでに顧客であるかどうかを確認する必要があるのです。彼がいない場合、私はFile writer(私はすでにコードを持っている)と新しいものを作るでしょう。
この予約システムの意味は、理髪師の予約をすることです。予約をReservations.txtと呼ばれる別のtxtファイルに入れなければなりません。そのファイルには、各予約時間と予約者が表示されます。
ありがとうございました!
これは私が既に持っているコードです: (いくつかのコメントはオランダ語であるが、私はそれらを翻訳します)
package nielbutaye;
import java.io.*;
import java.util.UUID;
/**
* @author Niel
*
*/
public class Klant {
//declaration that represents the text
public static String S;
public static String NEWLINE = System.getProperty("line.separator");
/**
* constructor
*/
public Klant(){}
/**
* @return
* By giving the name of the customer you will get all the data from the customer
*/
public double getCustomer() {
return 0 ;
}
/**
* Make a new customer
*/
public void setNew customer(){
// make a newSimpleInOutDialog
SimpleInOutDialog input = new SimpleInOutDialog("A new customer");
//input
S = "Name customer: " + input.readString("Give in your name:");
WriteToFile();
S = "Adress: " + input.readString("Give your adress");
WriteToFile();
S = "Telephonenummber: " + input.readString("Give your telephonenumber");
WriteToFile();
//making a customerID
UUID idCustomer = UUID.randomUUID();
S = "CustomerID: " + customerID.toString();
WriteToFile();
}
public void WriteToFile(){
try{
FileWriter writer = new FileWriter("L:\\Documents/Informatica/6de jaar/GIP/Customer.txt", true);
BufferedWriter out = new BufferedWriter(writer);
//Wrting away your data
out.write(S + NEWLINE);
//Closing the writer
out.close();
}catch (Exception e){//Catch when there are errors
System.err.println("Error: " + e.getMessage());
}
}
}
これまで持っていたコードを投稿できますか? – hmjd
@hmjd、更新された質問(: – PauloPawelo
JavaScriptタグのツールチップから: "... [JavaScript]はJavaと同じではありません" –