package cashForFiles;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class Cash {
    private Map<String, String> cashOfFiles = new HashMap<>();
    private String pathToFolder;

    public Cash(String pathToFolder) {
        this.pathToFolder = pathToFolder;
    }

    public String getFileContent(String name) {
        String content = cashOfFiles.get(name);
        if (content != null) {
            return content;
        }

        String pathToFile = String.format("%s%s%s",
                pathToFolder, File.separatorChar, name);
        File file = new File(pathToFile);

        if (!file.exists()) {
            return "file not exist";
        }

        FileRead reader = new FileRead(file);
        content = reader.read();

        cashOfFiles.put(name, content);

        return content;
    }
}

@@ -37,16 +37,52 @@
 o.File;%0A
+import java.lang.ref.SoftReference;%0A
 import j
@@ -162,35 +162,58 @@
 Map%3C
+SoftReference%3C
 String
+%3E
 , 
+SoftReference%3C
 String%3E
+%3E
  cash
-OfFiles
  = n
@@ -411,45 +411,76 @@
    S
-tring content = cashOfFiles.get
+oftReference%3CString%3E reference = cash.get(new SoftReference%3C%3E
 (name)
+)
 ;%0A  
@@ -489,23 +489,25 @@
     if (
-content
+reference
  != null
@@ -525,31 +525,39 @@
      return 
-content
+reference.get()
 ;%0A        %7D%0A
@@ -841,16 +841,23 @@
         
+String 
 content 
@@ -890,34 +890,68 @@
 cash
-OfFiles.put
+.put(new SoftReference%3C%3E
 (name
+)
 , 
+new SoftReference%3C%3E(
 content)
 ;%0A%0A 
@@ -946,18 +946,18 @@
 content)
+)
 ;
-%0A
 %0A       

edit cash with soft reference