@Test(expected = SRTReaderException.class) public void testReadFileDoesntExist() { SRTReader.read(new File("foo.srt")); }
public static SRTInfo read(File srtFile) throws InvalidSRTException, SRTReaderException { if (!srtFile.exists()) { throw new SRTReaderException(srtFile.getAbsolutePath() + " does not exist"); } if (!srtFile.isFile()) { throw new SRTReaderException(srtFile.getAbsolutePath() + " is not a regular file"); } SRTInfo srtInfo = new SRTInfo(); try (BufferedReader br = new BufferedReader(new FileReader(srtFile))) { BufferedLineReader reader = new BufferedLineReader(br); while (true) { srtInfo.add(parse(reader)); } } catch (EOFException e) { } catch (IOException e) { throw new SRTReaderException(e); } return srtInfo; }
SRTReader { public static SRTInfo read(File srtFile) throws InvalidSRTException, SRTReaderException { if (!srtFile.exists()) { throw new SRTReaderException(srtFile.getAbsolutePath() + " does not exist"); } if (!srtFile.isFile()) { throw new SRTReaderException(srtFile.getAbsolutePath() + " is not a regular file"); } SRTInfo srtInfo = new SRTInfo(); try (BufferedReader br = new BufferedReader(new FileReader(srtFile))) { BufferedLineReader reader = new BufferedLineReader(br); while (true) { srtInfo.add(parse(reader)); } } catch (EOFException e) { } catch (IOException e) { throw new SRTReaderException(e); } return srtInfo; } }
SRTReader { public static SRTInfo read(File srtFile) throws InvalidSRTException, SRTReaderException { if (!srtFile.exists()) { throw new SRTReaderException(srtFile.getAbsolutePath() + " does not exist"); } if (!srtFile.isFile()) { throw new SRTReaderException(srtFile.getAbsolutePath() + " is not a regular file"); } SRTInfo srtInfo = new SRTInfo(); try (BufferedReader br = new BufferedReader(new FileReader(srtFile))) { BufferedLineReader reader = new BufferedLineReader(br); while (true) { srtInfo.add(parse(reader)); } } catch (EOFException e) { } catch (IOException e) { throw new SRTReaderException(e); } return srtInfo; }  }
SRTReader { public static SRTInfo read(File srtFile) throws InvalidSRTException, SRTReaderException { if (!srtFile.exists()) { throw new SRTReaderException(srtFile.getAbsolutePath() + " does not exist"); } if (!srtFile.isFile()) { throw new SRTReaderException(srtFile.getAbsolutePath() + " is not a regular file"); } SRTInfo srtInfo = new SRTInfo(); try (BufferedReader br = new BufferedReader(new FileReader(srtFile))) { BufferedLineReader reader = new BufferedLineReader(br); while (true) { srtInfo.add(parse(reader)); } } catch (EOFException e) { } catch (IOException e) { throw new SRTReaderException(e); } return srtInfo; }  static SRTInfo read(File srtFile); }
SRTReader { public static SRTInfo read(File srtFile) throws InvalidSRTException, SRTReaderException { if (!srtFile.exists()) { throw new SRTReaderException(srtFile.getAbsolutePath() + " does not exist"); } if (!srtFile.isFile()) { throw new SRTReaderException(srtFile.getAbsolutePath() + " is not a regular file"); } SRTInfo srtInfo = new SRTInfo(); try (BufferedReader br = new BufferedReader(new FileReader(srtFile))) { BufferedLineReader reader = new BufferedLineReader(br); while (true) { srtInfo.add(parse(reader)); } } catch (EOFException e) { } catch (IOException e) { throw new SRTReaderException(e); } return srtInfo; }  static SRTInfo read(File srtFile);  }