Advertisement
Guest User

Untitled

a guest
Oct 1st, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1.     private void cat(String[] cmd) {
  2.         File f = new File(wd, cmd[1]);
  3.         BufferedReader br = null;
  4.  
  5.         try {
  6.             br = new BufferedReader(new FileReader(f));
  7.  
  8.             String line;
  9.             while ((line = br.readLine()) != null) {
  10.                 System.out.println(line);
  11.             }
  12.         } catch (FileNotFoundException fnf) {
  13.             System.out.println("file was not found");
  14.  
  15.         } catch (IOException e) {
  16.             e.printStackTrace();
  17.  
  18.         } finally {
  19.             try {
  20.                 if (br != null)
  21.                     br.close();
  22.             } catch (IOException e) {
  23.                 System.out.println("couldn't close br");
  24.             }
  25.         }
  26.  
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement