import java.util.*;

Introducing properties


public class Solution {
    public static Map<String, String> properties = new HashMap<>();

    public void fillInPropertiesMap() throws Exception {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(;
        String fileName = bufferedReader.readLine();
        try(FileInputStream inputStream = new FileInputStream(fileName)){

    public void save(OutputStream outputStream) throws Exception {
        Properties properties1 = new Properties();
        for(Map.Entry<String,String> entry: properties.entrySet()){
            properties1.setProperty(entry.getKey(), entry.getValue());

    public void load(InputStream inputStream) throws Exception {
        Properties properties1 = new Properties();
        Set<String> propertyNames = properties1.stringPropertyNames();
        for(String s: propertyNames){

    public static void main(String[] args) throws Exception {
        Solution solution = new Solution();
        BufferedReader bufferedReader1 = new BufferedReader(new InputStreamReader(;
        String fileName = bufferedReader1.readLine();
        try(FileOutputStream outputStream = new FileOutputStream(fileName)){

I've passed the task with the above code minus the code in the main method. That was just for me to try it out on my machine. But why do I get the following error after I pass in the first filename and after solution.fillInPropertiesMap(); finished it's work. Instead of getting the possibility to put in a second file name I get this: Exception in thread "main" Stream closed at at at sun.nio.cs.StreamDecoder.readBytes( at sun.nio.cs.StreamDecoder.implRead( at at at at at at com.codegym.task.task20.task2003.Solution.main( where line 44 is String fileName = bufferedReader1.readLine(); in my code. But as soon as I delete bufferedReader.close(); in line 15 everything works fine. But I opened a new stream. who is my "stream closed" apparently.