commit a03e2ab9c5ec6a232687628223b95ff51da01db8
parent b1ab911bf44138182274c52e33aa46cfedad6bd8
Author: Merlijn <[email protected]>
Date: Sun, 22 Jan 2023 12:35:45 +0100
Added auto merge
Diffstat:
2 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/src/main/java/nl/isygameclient/DataSaver.java b/src/main/java/nl/isygameclient/DataSaver.java
@@ -13,17 +13,19 @@ class DataSaver {
private String path;
private File file;
- public DataSaver(String filename) {
- this.createFile(filename);
-
+ public DataSaver(String path) {
+ this.path = path;
+ this.createFile();
}
public DataSaver() {
- this.createFile(this.randomString());
+ String name = this.randomString();
+ this.path = "./data/temp/" + name + ".csv";
+ this.createFile();
}
- public void createFile(String filename) {
- this.path = "./data/temp/" + filename + ".csv";
+ public void createFile() {
+ System.out.println(this.path);
this.file = new File(this.path);
try {
this.file.createNewFile();
@@ -59,13 +61,15 @@ class DataSaver {
}
}
- public void mergeFiles() {
- Set<String> files = this.getTempFiles(this.path);
+ public void mergeFiles(String path) {
+ Set<String> files = this.getTempFiles(path);
assert files != null;
for (String file : files) {
+ System.out.println("./data/temp/" + file);
try {
- BufferedReader bf = new BufferedReader(new FileReader(file));
+ BufferedReader bf = new BufferedReader(new FileReader("./data/temp/" + file));
+ bf.readLine();
String line = bf.readLine();
while (line != null) {
@@ -74,6 +78,7 @@ class DataSaver {
}
bf.close();
} catch (IOException ignore) {
+ System.out.println(ignore);
}
}
}
diff --git a/src/main/java/nl/isygameclient/Multithreading.java b/src/main/java/nl/isygameclient/Multithreading.java
@@ -5,17 +5,17 @@ import java.util.ArrayList;
public class Multithreading {
public static void main(String args[]) {
ArrayList<Headless> threaths = new ArrayList<>();
- int threads = 1;
+ int threads = 3;
for (int i = 0; i < threads; i++) {
- threaths.add(i, new Headless(2));
- threaths.get(i).start();
+ threaths.add(i, new Headless(1));
+ threaths.get(i).start();
}
}
}
class MergeFiles {
- public static void main(String args[]) {
- DataSaver dataSaver = new DataSaver("../Data");
- dataSaver.mergeFiles();
- }
+ public static void main(String args[]) {
+ DataSaver dataSaver = new DataSaver("./data/results.csv");
+ dataSaver.mergeFiles("./data/temp");
+ }
}
\ No newline at end of file