Помогите, пожалуйста! Прогоняю код - всё работает. Но валидатор не согласен.
package com.javarush.task.task20.task2003;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/*
Знакомство с properties
*/
public class Solution extends Properties {
public static Map<String, String> properties = new HashMap<>();
public void fillInPropertiesMap() {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
String filename = reader.readLine();
InputStream inputStream = new FileInputStream(filename);
load(inputStream);
// File yourFile = File.createTempFile(filename, ".properties");
// OutputStream outputStream = new FileOutputStream(yourFile);
OutputStream outputStream = new FileOutputStream(filename);
save(outputStream);
outputStream.flush();
reader.close();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
System.out.println("smth wrong with load/ save");
e.printStackTrace();
}
//implement this method - реализуйте этот метод
}
public void save(OutputStream outputStream) throws Exception {
PrintWriter writer = new PrintWriter(outputStream);
boolean noProperties = properties.isEmpty();
writer.println(noProperties);
if (!noProperties) {
for (Map.Entry<String, String> pair : properties.entrySet()
) {
String key = pair.getKey();
String value = pair.getValue();
writer.print(key + ":");
writer.println(value);
}
}
writer.flush();
//implement this method - реализуйте этот метод
}
public void load(InputStream inputStream) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String noProperties = reader.readLine();
if (noProperties.equals("false")) {
while (reader.ready()) {
String keyValue = reader.readLine();
String[] keyAndValue = keyValue.split(":");
properties.put(keyAndValue[0], keyAndValue[1]);
}
}
//implement this method - реализуйте этот метод
}
public static void main(String[] args) {
Solution solution = new Solution();
solution.fillInPropertiesMap();
}
}