Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //reads text from the line at rI
- public static String getQuestion(String in, int rI){
- LineNumberReader br = null;
- String doc = in;
- String thisLine ="";
- while(rI%2==0){
- rI++;
- }
- try{
- br = new LineNumberReader(new FileReader(doc));
- while((thisLine = br.readLine()) != null){
- if(br.getLineNumber() == rI){
- return thisLine;
- }
- }
- }catch(IOException ee){
- System.err.println("Error: " + ee);
- }finally{
- try{
- if(br != null){
- br.close();
- }
- }catch(IOException ex){
- }
- }
- System.out.println(rI);
- return thisLine;
- }
- //reads text from the line down from rI
- public static String getAnswer(String in, int rI){
- String doc = in;
- String thisLine="";
- LineNumberReader br = null;
- try{
- br = new LineNumberReader(new FileReader(doc));
- while((thisLine = br.readLine()) != null){
- if(br.getLineNumber() == rI +1){
- return "The correct answer was: " + thisLine + "\nIf you feel your answer might be questioned, please see Mr. Engel.";
- }
- }
- }catch(IOException ee){
- System.err.println("Error: " + ee);
- }finally{
- try{
- if(br != null){
- br.close();
- }
- }catch(IOException ex){
- }
- }
- System.out.println(rI);
- return thisLine;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement