mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Renamed method for clarity.
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -8520,7 +8520,7 @@ src/forge/EndOfCombat.java -text svneol=native#text/plain
|
|||||||
src/forge/EndOfTurn.java svneol=native#text/plain
|
src/forge/EndOfTurn.java svneol=native#text/plain
|
||||||
src/forge/ExternalPanel.java svneol=native#text/plain
|
src/forge/ExternalPanel.java svneol=native#text/plain
|
||||||
src/forge/FileFinder.java -text svneol=native#text/plain
|
src/forge/FileFinder.java -text svneol=native#text/plain
|
||||||
src/forge/FileUtil.java -text svneol=native#text/plain
|
src/forge/FileUtil.java svneol=native#text/plain
|
||||||
src/forge/GUI_DeckAnalysis.java -text svneol=native#text/plain
|
src/forge/GUI_DeckAnalysis.java -text svneol=native#text/plain
|
||||||
src/forge/GUI_Filter.java -text svneol=native#text/plain
|
src/forge/GUI_Filter.java -text svneol=native#text/plain
|
||||||
src/forge/GUI_ImportPicture.java -text svneol=native#text/plain
|
src/forge/GUI_ImportPicture.java -text svneol=native#text/plain
|
||||||
|
|||||||
@@ -1,71 +1,68 @@
|
|||||||
package forge;
|
package forge;
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.BufferedWriter;
|
import forge.error.ErrorViewer;
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
import java.io.*;
|
||||||
import java.io.FileWriter;
|
import java.util.ArrayList;
|
||||||
import java.util.ArrayList;
|
import java.util.Collections;
|
||||||
import java.util.Collections;
|
import java.util.List;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import forge.error.ErrorViewer;
|
public class FileUtil {
|
||||||
|
public static boolean doesFileExist(String filename) {
|
||||||
|
File f = new File(filename);
|
||||||
public class FileUtil {
|
return f.exists();
|
||||||
public static boolean doesFileExist(String filename) {
|
}
|
||||||
File f = new File(filename);
|
|
||||||
return f.exists();
|
public static void writeFile(String filename, List<String> data) {
|
||||||
}
|
writeFile(new File(filename), data);
|
||||||
|
}
|
||||||
public static void writeFile(String filename, List<String> data) {
|
|
||||||
writeFile(new File(filename), data);
|
//writes each element of ArrayList on a separate line
|
||||||
}
|
//this is used to write a file of Strings
|
||||||
|
//this will create a new file if needed
|
||||||
//writes each element of ArrayList on a separate line
|
//if filename already exists, it is deleted
|
||||||
//this is used to write a file of Strings
|
public static void writeFile(File file, List<String> data) {
|
||||||
//this will create a new file if needed
|
try {
|
||||||
//if filename already exists, it is deleted
|
Collections.sort(data);
|
||||||
public static void writeFile(File file, List<String> data) {
|
|
||||||
try {
|
BufferedWriter io = new BufferedWriter(new FileWriter(file));
|
||||||
Collections.sort(data);
|
for(int i = 0; i < data.size(); i++)
|
||||||
|
io.write(data.get(i) + "\r\n");
|
||||||
BufferedWriter io = new BufferedWriter(new FileWriter(file));
|
|
||||||
for(int i = 0; i < data.size(); i++)
|
io.flush();
|
||||||
io.write(data.get(i) + "\r\n");
|
io.close();
|
||||||
|
} catch(Exception ex) {
|
||||||
io.flush();
|
ErrorViewer.showError(ex);
|
||||||
io.close();
|
throw new RuntimeException("FileUtil : writeFile() error, problem writing file - " + file + " : " + ex);
|
||||||
} catch(Exception ex) {
|
}
|
||||||
ErrorViewer.showError(ex);
|
}//writeAllDecks()
|
||||||
throw new RuntimeException("FileUtil : writeFile() error, problem writing file - " + file + " : " + ex);
|
|
||||||
}
|
public static ArrayList<String> readFile(String filename) {
|
||||||
}//writeFile()
|
return readFile(new File(filename));
|
||||||
|
}
|
||||||
public static ArrayList<String> readFile(String filename) {
|
|
||||||
return readFile(new File(filename));
|
//reads line by line and adds each line to the ArrayList
|
||||||
}
|
//this will return blank lines as well
|
||||||
|
//if filename not found, returns an empty ArrayList
|
||||||
//reads line by line and adds each line to the ArrayList
|
public static ArrayList<String> readFile(File file) {
|
||||||
//this will return blank lines as well
|
ArrayList<String> list = new ArrayList<String>();
|
||||||
//if filename not found, returns an empty ArrayList
|
BufferedReader in;
|
||||||
public static ArrayList<String> readFile(File file) {
|
|
||||||
ArrayList<String> list = new ArrayList<String>();
|
try {
|
||||||
BufferedReader in;
|
if(file == null || !file.exists()) return list;
|
||||||
|
|
||||||
try {
|
|
||||||
if(file == null || !file.exists()) return list;
|
in = new BufferedReader(new FileReader(file));
|
||||||
|
|
||||||
|
String line;
|
||||||
in = new BufferedReader(new FileReader(file));
|
while((line = in.readLine()) != null)
|
||||||
|
list.add(line);
|
||||||
String line;
|
} catch(Exception ex) {
|
||||||
while((line = in.readLine()) != null)
|
ErrorViewer.showError(ex);
|
||||||
list.add(line);
|
throw new RuntimeException("FileUtil : readFile() error, " + ex);
|
||||||
} catch(Exception ex) {
|
}
|
||||||
ErrorViewer.showError(ex);
|
|
||||||
throw new RuntimeException("FileUtil : readFile() error, " + ex);
|
return list;
|
||||||
}
|
}//readFile()
|
||||||
|
|
||||||
return list;
|
|
||||||
}//readFile()
|
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ public class DeckManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
writeFile();
|
writeAllDecks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -262,7 +262,7 @@ public class DeckManager {
|
|||||||
return deckName.replaceAll("[^-_$#@.{[()]} a-zA-Z0-9]", "");
|
return deckName.replaceAll("[^-_$#@.{[()]} a-zA-Z0-9]", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeFile() {
|
public void writeAllDecks() {
|
||||||
try {
|
try {
|
||||||
//store the files that do exist
|
//store the files that do exist
|
||||||
List<File> files = new ArrayList<File>();
|
List<File> files = new ArrayList<File>();
|
||||||
|
|||||||
Reference in New Issue
Block a user