@Test public void testWrite() throws Exception { SRTInfo inInfo = new SRTInfo(); inInfo.add(new SRT(2, SRTTimeFormat.parse("00:00:24,600"), SRTTimeFormat.parse("00:00:27,800"), "Foo Bar", "Bar Foo")); inInfo.add(new SRT(1, SRTTimeFormat.parse("00:00:20,000"), SRTTimeFormat.parse("00:00:24,400"), "Hello World", "Bye World")); File srtFile = new File("src/test/resources/test1.srt"); SRTWriter.write(srtFile, inInfo); SRTInfo outInfo = SRTReader.read(srtFile); assertEquals(inInfo.size(), outInfo.size()); Iterator<SRT> inIter = inInfo.iterator(); Iterator<SRT> outIter = outInfo.iterator(); SRT inSRT = inIter.next(); SRT outSRT = outIter.next(); assertEquals(inSRT.number, outSRT.number); assertEquals(SRTTimeFormat.format(inSRT.startTime), SRTTimeFormat.format(outSRT.startTime)); assertEquals(SRTTimeFormat.format(inSRT.endTime), SRTTimeFormat.format(outSRT.endTime)); assertEquals(inSRT.text.get(0), outSRT.text.get(0)); assertEquals(inSRT.text.get(1), outSRT.text.get(1)); inSRT = inIter.next(); outSRT = outIter.next(); assertEquals(inSRT.number, outSRT.number); assertEquals(SRTTimeFormat.format(inSRT.startTime), SRTTimeFormat.format(outSRT.startTime)); assertEquals(SRTTimeFormat.format(inSRT.endTime), SRTTimeFormat.format(outSRT.endTime)); assertEquals(inSRT.text.get(0), outSRT.text.get(0)); assertEquals(inSRT.text.get(1), outSRT.text.get(1)); }
public static void write(File srtFile, SRTInfo srtInfo) throws SRTWriterException { try (PrintWriter pw = new PrintWriter(srtFile)) { for (SRT srt : srtInfo) { pw.println(srt.number); pw.println( SRTTimeFormat.format(srt.startTime) + SRTTimeFormat.TIME_DELIMITER + SRTTimeFormat.format(srt.endTime)); for (String text : srt.text) { pw.println(text); } pw.println(); } } catch (IOException e) { throw new SRTWriterException(e); } }
SRTWriter { public static void write(File srtFile, SRTInfo srtInfo) throws SRTWriterException { try (PrintWriter pw = new PrintWriter(srtFile)) { for (SRT srt : srtInfo) { pw.println(srt.number); pw.println( SRTTimeFormat.format(srt.startTime) + SRTTimeFormat.TIME_DELIMITER + SRTTimeFormat.format(srt.endTime)); for (String text : srt.text) { pw.println(text); } pw.println(); } } catch (IOException e) { throw new SRTWriterException(e); } } }
SRTWriter { public static void write(File srtFile, SRTInfo srtInfo) throws SRTWriterException { try (PrintWriter pw = new PrintWriter(srtFile)) { for (SRT srt : srtInfo) { pw.println(srt.number); pw.println( SRTTimeFormat.format(srt.startTime) + SRTTimeFormat.TIME_DELIMITER + SRTTimeFormat.format(srt.endTime)); for (String text : srt.text) { pw.println(text); } pw.println(); } } catch (IOException e) { throw new SRTWriterException(e); } } SRTWriter(); }
SRTWriter { public static void write(File srtFile, SRTInfo srtInfo) throws SRTWriterException { try (PrintWriter pw = new PrintWriter(srtFile)) { for (SRT srt : srtInfo) { pw.println(srt.number); pw.println( SRTTimeFormat.format(srt.startTime) + SRTTimeFormat.TIME_DELIMITER + SRTTimeFormat.format(srt.endTime)); for (String text : srt.text) { pw.println(text); } pw.println(); } } catch (IOException e) { throw new SRTWriterException(e); } } SRTWriter(); static void write(File srtFile, SRTInfo srtInfo); }
SRTWriter { public static void write(File srtFile, SRTInfo srtInfo) throws SRTWriterException { try (PrintWriter pw = new PrintWriter(srtFile)) { for (SRT srt : srtInfo) { pw.println(srt.number); pw.println( SRTTimeFormat.format(srt.startTime) + SRTTimeFormat.TIME_DELIMITER + SRTTimeFormat.format(srt.endTime)); for (String text : srt.text) { pw.println(text); } pw.println(); } } catch (IOException e) { throw new SRTWriterException(e); } } SRTWriter(); static void write(File srtFile, SRTInfo srtInfo);  }