Моя проблема в , из-за которой я не могу понять, как читать имя клиента с помощью File Reader.
Я делаю систему бронирования и мне уже нужно знать клиентасуществовать.Вот почему я должен прочитать свой файл Customers.txt, чтобы проверить, является ли кто-то уже клиентом.Если он не будет, я сделаю новый с File Writer (у меня уже есть код).
Смысл этой системы бронирования - бронировать с помощью парикмахера.Я должен поместить оговорки в другой текстовый файл с именем Reservations.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());
}
}
}