This commit is contained in:
Sabine Gubitz 2022-11-24 13:59:26 +01:00
commit 88d1b3a1af
12 changed files with 115 additions and 0 deletions

3
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

1
.idea/.name Normal file
View File

@ -0,0 +1 @@
Execute.java

6
.idea/misc.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/VPR_SCRIPT.iml" filepath="$PROJECT_DIR$/VPR_SCRIPT.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

11
VPR_SCRIPT.iml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

Binary file not shown.

Binary file not shown.

13
src/Execute.java Normal file
View File

@ -0,0 +1,13 @@
import java.util.ArrayList;
/**The class Execute is the executen file for the whole programm.
*/
public class Execute {
public static void main (String[]args){
ArrayList<String> data = GeneralMethods.readData("test.csv");
for(String d : data){
System.out.println(d);
}
GeneralMethods.writeData("test2.csv",data);
}
}

53
src/GeneralMethods.java Normal file
View File

@ -0,0 +1,53 @@
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
/**GeneralMethods is a class for commen public methods.
*
* @auhtor Felix Wöstemeyer
*
* @version 1.0
*/
public class GeneralMethods {
/**The method readData gives back an ArrayList from the data of a given file.
*
* @param pathRead the given filepath to read
* @return returns an ArrayList of Strings with the read data
*/
public static ArrayList<String> readData(String pathRead){
try {
ArrayList<String> data = new ArrayList<String>();
List<String> lines = Files.readAllLines(Paths.get(pathRead));
for(String line : lines){
data.add(line);
}
return data;
} catch (IOException e) {
e.printStackTrace();
return new ArrayList<String>();
}
}
/**The method writeData saves the given data to a certain file.
*
* @param pathWrite the given filepath to write
* @param data the data to be saved
*/
public static void writeData(String pathWrite, ArrayList<String> data){
try{
BufferedWriter writer = new BufferedWriter(new FileWriter(pathWrite));
for (String d : data) {
writer.write(d);
writer.newLine();
}
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

7
test.csv Normal file
View File

@ -0,0 +1,7 @@
erstdfzg
rsedtfgzhu
ersdtfgzhuji
trdfzghui
rtdfzu
t
dztdrs5456
1 erstdfzg
2 rsedtfgzhu
3 ersdtfgzhuji
4 trdfzghui
5 rtdfzu
6 t
7 dztdrs5456

7
test2.csv Normal file
View File

@ -0,0 +1,7 @@
erstdfzg
rsedtfgzhu
ersdtfgzhuji
trdfzghui
rtdfzu
t
dztdrs5456
1 erstdfzg
2 rsedtfgzhu
3 ersdtfgzhuji
4 trdfzghui
5 rtdfzu
6 t
7 dztdrs5456