Hi Team,
Please help me to find the validation errors as i could not able to find one.
Regards,
Manish
package com.codegym.task.task20.task2003;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Solution {
public static Map<String, String> properties = new HashMap<>();
public void fillInPropertiesMap() throws Exception {
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
String fileName=reader.readLine();
FileInputStream readFile=new FileInputStream(fileName);
load(readFile);
}
public void save(OutputStream outputStream) throws Exception {
PrintWriter writer = new PrintWriter(outputStream);
// String isPropertiesEmpty= (properties != null)? "yes":"no";
// writer.println(isPropertiesEmpty);
// writer.flush();
if (!properties.isEmpty()) {
for (Map.Entry<String, String> readProperty : properties.entrySet()
) {
String key = readProperty.getKey();
String value = readProperty.getValue();
writer.println(key + " " + value);
}
writer.flush();
}
}
public void load(InputStream inputStream) throws Exception {
Scanner reader = new Scanner(inputStream);
// String isPropertiesPresent=reader.nextLine();
// if(isPropertiesPresent.equals("yes")){
properties=new HashMap<>();
while(reader.hasNext()){
String string=reader.nextLine();
//considering properties are stored as key=value in file
String strings[]=string.split(" ");
String string1=strings[0];
String string2=strings[1];
properties.put(string1,string2);
}
// }
}
public static void main(String[] args) {
}
}