@Test public void testRead() throws Exception { SRTInfo info = SRTReader.read(new File("src/test/resources/good.srt")); assertEquals(2, info.size()); Iterator<SRT> iter = info.iterator(); SRT srt = iter.next(); assertEquals(1, srt.number); assertEquals("Hello World", srt.text.get(0)); assertEquals("00:00:20,000", SRTTimeFormat.format(srt.startTime)); assertEquals("00:00:24,400", SRTTimeFormat.format(srt.endTime)); assertEquals("Bye World", srt.text.get(1)); srt = iter.next(); assertEquals(2, srt.number); assertEquals("00:00:24,600", SRTTimeFormat.format(srt.startTime)); assertEquals("00:00:27,800", SRTTimeFormat.format(srt.endTime)); assertEquals("Foo Bar", srt.text.get(0)); assertEquals("Bar Foo", srt.text.get(1)); }
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);  }