Answer the question
In order to leave comments, you need to log in
An exception is thrown when it shouldn't. What is the problem?
The file contains data about RectButton (4 coordinates, state and text). You need to read them and create a new RectButton based on them
public static RectButton readRectButtonFromTextFileSixLines(File file) throws IOException, WindowException {
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)))) {
int[] array = new int[4];
String state, text;
array[0] = br.read();
br.readLine();
array[1] = br.read();
br.readLine();
array[2] = br.read();
br.readLine();
array[3] = br.read();
br.readLine();
state = br.readLine();
text = br.readLine();
return new RectButton(array[0], array[1], array[2], array[3], state, text);
} catch (FileNotFoundException e) {
throw new FileNotFoundException();
} catch (UnsupportedEncodingException e) {
throw new FileNotFoundException();
} catch (IOException e) {
throw new IOException();
}
}
Answer the question
In order to leave comments, you need to log in
String comparison in java is not done through == or !=, but through the String methodequals
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question