Guest User

Untitled

a guest
May 27th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. public class Disk {
  2. private File outfile;
  3. private File infile;
  4. public PrintWriter out;
  5. public BufferedReader in;
  6.  
  7. public Disk (String filename,String io){
  8. if(io.equals("out")){
  9. outfile = new File(filename);
  10. try{
  11. out = new PrintWriter(new FileWriter(outfile));
  12. }catch(Exception e1){
  13. System.out.println("Error in Constructor Call");
  14. }
  15. }
  16. if(io.equals("in")){
  17. infile = new File(filename);
  18. try{
  19. in = new BufferedReader(new FileReader(infile));
  20. }catch(FileNotFoundException e2) {
  21. System.out.println(filename + " not found");
  22. }
  23. }
  24. }
  25.  
  26. public String readLine(){
  27. String line = null;
  28. try{
  29. line = in.readLine();
  30. }catch(java.io.IOException e){
  31. System.out.println("input line not valid");
  32. }
  33. return line;
  34. }
  35. }
Add Comment
Please, Sign In to add comment