more
This commit is contained in:
@@ -1,6 +1,30 @@
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
|
// Read contents of inFile, convert it all to uppercase, write to outFile
|
||||||
|
// Do line-by-line
|
||||||
|
|
||||||
|
public static void upperCaseFileConverter(String inFile, String outFile) {
|
||||||
|
try {
|
||||||
|
BufferedReader in = new BufferedReader(new FileReader(inFile));
|
||||||
|
BufferedWriter out = new BufferedWriter(new FileWriter(outFile));
|
||||||
|
|
||||||
|
String line;
|
||||||
|
|
||||||
|
while((line = in.readLine()) != null) {
|
||||||
|
out.write(line.toUpperCase());
|
||||||
|
//out.newLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
System.out.println("File not found:");
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
|
||||||
@@ -13,7 +37,7 @@ public class Main {
|
|||||||
testScoresArray[0] = new TestScores(new int[]{15, 24, 44, 30});
|
testScoresArray[0] = new TestScores(new int[]{15, 24, 44, 30});
|
||||||
testScoresArray[1] = new TestScores(new int[]{69, 69, 55, 88, 92});
|
testScoresArray[1] = new TestScores(new int[]{69, 69, 55, 88, 92});
|
||||||
testScoresArray[2] = new TestScores(new int[]{82, 75, 89, 90, 0});
|
testScoresArray[2] = new TestScores(new int[]{82, 75, 89, 90, 0});
|
||||||
testScoresArray[3] = new TestScores(new int[]{72, 87, 92, 92, 94});
|
testScoresArray[3] = new TestScores(new int[]{72, 87, 92, 92, 96});
|
||||||
testScoresArray[4] = new TestScores(new int[]{100,100,100,100,100,100,100});
|
testScoresArray[4] = new TestScores(new int[]{100,100,100,100,100,100,100});
|
||||||
|
|
||||||
for(TestScores testScore : testScoresArray) {
|
for(TestScores testScore : testScoresArray) {
|
||||||
@@ -29,7 +53,7 @@ public class Main {
|
|||||||
System.out.println("Test Scores written to " + filename);
|
System.out.println("Test Scores written to " + filename);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
System.out.println(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deserialize objects from file
|
// Deserialize objects from file
|
||||||
@@ -43,14 +67,21 @@ public class Main {
|
|||||||
}
|
}
|
||||||
//TODO: FIX THESE CATCH CLAUSES
|
//TODO: FIX THESE CATCH CLAUSES
|
||||||
catch(IOException e){
|
catch(IOException e){
|
||||||
e.printStackTrace();
|
System.out.println(e.getMessage());
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
for(TestScores testScore : deserializedScores) {
|
for (TestScores testScore : deserializedScores) {
|
||||||
System.out.println(testScore.getAverage());
|
System.out.println(testScore.getAverage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch(NullPointerException e){
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
upperCaseFileConverter("input.txt", "output.txt");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TestScores class will take an array of test Scores, and has a method to determine average
|
* TestScores class will take an array of test Scores, and has a method to determine average
|
||||||
*/
|
*/
|
||||||
public class TestScores implements Serializable {
|
public class TestScores implements Serializable {
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
int[] scores; // The array of test scores
|
int[] scores; // The array of test scores
|
||||||
|
|
||||||
|
|||||||
3
src/input.txt
Normal file
3
src/input.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Hello World!
|
||||||
|
This is a file, that
|
||||||
|
Has words and stuff in it
|
||||||
Reference in New Issue
Block a user