properties бросает в консоль null
Почему я чего то не понимаю......
package com.javarush.task.task20.task2003;
import java.io.*;
import java.nio.Buffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/*
Знакомство с properties
*/
public class Solution {
public static Map<String, String> runtimeStorage = new HashMap<>();
public static void save(OutputStream outputStream) throws Exception {
//напишите тут ваш код
Properties properties = new Properties();
}
public static void load(InputStream inputStream) throws IOException {
//напишите тут ваш код
BufferedReader input = new BufferedReader(new InputStreamReader(inputStream));
ArrayList<String> listDuplicate = new ArrayList<>();
while (input.ready()){
listDuplicate.add(input.readLine());
}
File tempFile = File.createTempFile("data",".properties");
BufferedWriter fileWriterForTempFileBuff = new BufferedWriter(new FileWriter(tempFile));
for (int i=0; i<listDuplicate.size(); i++){
fileWriterForTempFileBuff.write(listDuplicate.get(i));
}
BufferedReader readTempFile = new BufferedReader(new FileReader(tempFile.getCanonicalPath()));
Properties properties = new Properties();
properties.load(readTempFile);
String keyInLine = "";
for (int b=0; b<listDuplicate.size(); b++){
if (!(listDuplicate.get(b).contains("! ")) & !(listDuplicate.get(b).contains("# "))){
keyInLine = listDuplicate.get(b);
if (listDuplicate.get(b).endsWith("\\")){
b+=1;
keyInLine += listDuplicate.get(b);
}
String stValue = "";
int endIndexLine = 0;
for (int val=1; val<keyInLine.length()-1; val++){
if (keyInLine.substring(val-1,val).equals("=")){
stValue = "=";
endIndexLine = val-1;
break;
} else if (keyInLine.substring(val-1,val).equals(":")){
stValue = ":";
endIndexLine = val-1;
break;
}
}
if (stValue.contains("=")){
System.out.print(keyInLine.substring(0,endIndexLine));
System.out.println(properties.getProperty(keyInLine.substring(0,endIndexLine)));
} else if (stValue.contains(":")){
System.out.print(keyInLine.substring(0,endIndexLine));
System.out.println(properties.getProperty(keyInLine.substring(0,endIndexLine)));
}
keyInLine = "";
}
}
tempFile.deleteOnExit();
}
public static void main(String[] args) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
FileInputStream fos = new FileInputStream("D:/edit.properties")) {
load(fos);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(runtimeStorage);
}
}