Skip to content

Instantly share code, notes, and snippets.

@niallcurtis
Created April 3, 2017 19:57
Show Gist options
  • Save niallcurtis/e645f2ffa7afd2a571d4be3b8af9d807 to your computer and use it in GitHub Desktop.
Save niallcurtis/e645f2ffa7afd2a571d4be3b8af9d807 to your computer and use it in GitHub Desktop.
JavaCoursework3
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinCommonCompilerArguments">
<option name="languageVersion" value="1.1" />
<option name="apiVersion" value="1.1" />
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Coursework3.iml" filepath="$PROJECT_DIR$/Coursework3.iml" />
</modules>
</component>
</project>
<?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>
—x public class Reader
—> public class Binary extends Reader
—> public class Text extends Reader
package uk.co.niallcurtis.JavaCoursework3;
/**
* Created by niall on 03/04/2017.
*/
public class Question1 {
}
package uk.co.niallcurtis.JavaCoursework3;
/**
* Created by niall on 03/04/2017.
*/
public class QuestionOne {
public static void main(String[] args) {
TextReader test = new TextReader();
try {
test.readFile("test.txt");
}
catch (Exception e){
e.printStackTrace();
}
}
}
package uk.co.niallcurtis.JavaCoursework3;
import java.io.IOException;
import java.io.*;
import java.util.ArrayList;
/**
* Created by niall on 03/04/2017.
*/
public class TextReader {
private ArrayList txtReader(String filename) throws IOException{
FileReader readFile = new FileReader(filename);
BufferedReader inFile = new BufferedReader(readFile);
ArrayList lines = new ArrayList();
String currentLine;
// Line reader tool used in Reading-Writing lectures
while((currentLine = inFile.readLine()) != null) {
lines.add(currentLine);
}
inFile.close();
return lines;
}
private String binaryReader(String filename) {
return filename;
}
public ArrayList readFile(String filename) throws IOException {
return txtReader(filename);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment