-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileManager.java
More file actions
68 lines (63 loc) · 1.43 KB
/
Copy pathFileManager.java
File metadata and controls
68 lines (63 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* @author REYYAN OFLAZ
* @version 1.0
*/
import java.io.*;
public class FileManager{
public static BufferedReader buffReadManager;
public static BufferedWriter buffWriteManager;
public static FileWriter fileWriter;
public static File fileMng;
public static File fileMng2;
public static String lineManager;
public static FileReader fileReader;
/**
* open and read file the file
* @param file
* @throws
* @return BufferedReader object
*/
public static BufferedReader openFile(String file) throws IOException{
try{
fileMng= new File(file);
fileReader = new FileReader(fileMng);
buffReadManager= new BufferedReader(fileReader);
return buffReadManager;
}
catch(Exception e){
throw new IOException();
}
}
/**
* writes to the file
* @param file
* @throws
* @return BufferedWriter object
*/
public static BufferedWriter writeFile (String file) throws IOException{
try{
fileMng2 = new File(file);
fileWriter = new FileWriter(fileMng);
buffWriteManager= new BufferedWriter(fileWriter);
return buffWriteManager;
}
catch(Exception e){
throw new IOException();
}
}
/**
* Closes this file
* @param buffered reader object
* @throws IOException
*/
public static void closeReaderFile(BufferedReader br) throws IOException{
if(br!=null){
br.close();
}
}
public static void closeWriterFile(BufferedWriter bw) throws IOException{
if(bw!=null){
bw.close();
}
}
}