SHARE
TWEET

Untitled

a guest Jan 21st, 2020 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Exam {
  2.    
  3.     List<Question> question = new ArrayList<>();
  4.    
  5.     //Liest den Tex-Header aus einer Datei u. gibt ihn als String zurück
  6.     String readHeaderFromFile() {
  7.         ///...
  8.         return "Hier steht der Header";
  9.     }
  10.    
  11.     public void readQuestions()throws IOException{
  12.        
  13.         try(BufferedReader br = new BufferedReader(new FileReader("C:/Users/Chris/Desktop/question.csv"))) {
  14.            
  15.             String s = br.readLine();
  16.            
  17.             while(s != null) {
  18.                
  19.                 if(s != null) {
  20.                     question.add(Question.toQuestion(s));
  21.                 }
  22.                 s = br.readLine();
  23.             }
  24.         }catch(FileNotFoundException e) {
  25.             System.out.println("File not found");
  26.         }
  27.     }
  28.    
  29.     public void toTest() throws IOException{
  30.        
  31.         try(BufferedWriter bw = new BufferedWriter(new FileWriter("C:/Users/Chris/Desktop/text.tex"))) {
  32.            
  33.             String header = readHeaderFromFile();
  34.             if(header != null) {
  35.                 bw.write(header);
  36.                 bw.newLine();
  37.             }
  38.            
  39.             for(Question q : question) {
  40.                 bw.write("\\textbf{"+q.text +"}\\");
  41.                 bw.newLine();
  42.             }
  43.             bw.write("\\end{document}");
  44.         }
  45.        
  46.     }
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top