package model;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
import java.io.FileReader;
/**
 * Created by Elliad on 2016-05-08.
 */
public class FileModel {
    private static FileModel instance;
    private static File fileL;
    private static File fileR;
    private static String stringL = "";
    private static String stringR = "";
    private FileModel() { // 기본 생성자
    }
    public static FileModel getModel() { // 1개의 객체를 유지하기 위한 싱글톤
       if(instance == null)
           instance = new FileModel();
        return instance;
    }

    public boolean readFileR(String fileRPath) { // 파일명 받기 및 읽기.
        fileR= new File(fileRPath);
        try(Scanner in = new Scanner(new FileReader(fileRPath)))
        {
            stringR = in.useDelimiter("\\Z").next();
        } catch (FileNotFoundException e) {

            e.printStackTrace();
            return false;
        }
        return true;
    }
    public boolean readFileL(String fileLPath) { // 파일명 받기 및 읽기.
        fileL = new File(fileLPath);
        try(Scanner in = new Scanner(new FileReader(fileLPath)))
        {
            stringL = in.useDelimiter("\\Z").next();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }
    public String getStringR()
    {
        return stringR;
    }

    public String getStringL()
    {
        return stringL;
    }

    public boolean writeFileL(String fileLPath) { // 파일명 받기 및 읽기
        try(  PrintWriter out = new PrintWriter(fileLPath) ){
            out.print(stringL);
            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }
    public boolean writeFileR(String fileRPath) { // 파일명 받기 및 읽기
        try(  PrintWriter out = new PrintWriter(fileRPath) ){
            out.print(stringR);
            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }

}

@@ -289,40 +289,8 @@
 file
-L;%0A    private static File fileR
 ;%0A  
@@ -323,49 +323,8 @@
 ring
-L = %22%22;%0A    private static String stringR
  = %22
@@ -554,25 +554,24 @@
 ean readFile
-R
 (String file
@@ -562,33 +562,32 @@
 File(String file
-R
 Path) %7B // %ED%8C%8C%EC%9D%BC%EB%AA%85 %EB%B0%9B
@@ -606,17 +606,16 @@
     file
-R
 = new Fi
@@ -617,25 +617,24 @@
 ew File(file
-R
 Path);%0A     
@@ -680,25 +680,24 @@
 eReader(file
-R
 Path)))%0A    
@@ -720,17 +720,16 @@
   string
-R
  = in.us
@@ -910,395 +910,24 @@
 lic 
-boolean readFileL(String fileLPath) %7B // %ED%8C%8C%EC%9D%BC%EB%AA%85 %EB%B0%9B%EA%B8%B0 %EB%B0%8F %EC%9D%BD%EA%B8%B0.%0A        fileL = new File(fileLPath);%0A        try(Scanner in = new Scanner(new FileReader(fileLPath)))%0A        %7B%0A            stringL = in.useDelimiter(%22%5C%5CZ%22).next();%0A        %7D catch (FileNotFoundException e) %7B%0A            e.printStackTrace();%0A            return false;%0A        %7D%0A        return true;%0A    %7D%0A    public String getStringR
+String getString
 ()%0A 
@@ -952,17 +952,16 @@
 n string
-R
 ;%0A    %7D%0A
@@ -965,75 +965,8 @@
  %7D%0A%0A
-    public String getStringL()%0A    %7B%0A        return stringL;%0A    %7D%0A
 %0A   
@@ -990,17 +990,16 @@
 riteFile
-L
 (String 
@@ -998,25 +998,24 @@
 (String file
-L
 Path) %7B // %ED%8C%8C
@@ -1077,17 +1077,16 @@
 ter(file
-L
 Path) )%7B
@@ -1118,333 +1118,8 @@
 ring
-L);%0A            out.close();%0A        %7D catch (FileNotFoundException e) %7B%0A            e.printStackTrace();%0A            return false;%0A        %7D%0A        return true;%0A    %7D%0A    public boolean writeFileR(String fileRPath) %7B // %ED%8C%8C%EC%9D%BC%EB%AA%85 %EB%B0%9B%EA%B8%B0 %EB%B0%8F %EC%9D%BD%EA%B8%B0%0A        try(  PrintWriter out = new PrintWriter(fileRPath) )%7B%0A            out.print(stringR
 );%0A 

Change Filemodel for efficienty. 효율성을 위해 Filemodel 구조를 변경하였습니다