@Test public void testLoadOneAction() throws Exception { ActionFile actionFile = getActionFile("offline/action_file_one_action.exi"); DownloadRequest[] actions = actionFile.load(); assertThat(actions).hasLength(1); assertThat(actions[0]).isEqualTo(expectedAction1); }
public DownloadRequest[] load() throws IOException { if (!exists()) { return new DownloadRequest[0]; } InputStream inputStream = null; try { inputStream = atomicFile.openRead(); DataInputStream dataInputStream = new DataInputStream(inputStream); int version = dataInputStream.readInt(); if (version > VERSION) { throw new IOException("Unsupported action file version: " + version); } int actionCount = dataInputStream.readInt(); ArrayList<DownloadRequest> actions = new ArrayList<>(); for (int i = 0; i < actionCount; i++) { try { actions.add(readDownloadRequest(dataInputStream)); } catch (UnsupportedRequestException e) { } } return actions.toArray(new DownloadRequest[0]); } finally { Util.closeQuietly(inputStream); } }
ActionFile { public DownloadRequest[] load() throws IOException { if (!exists()) { return new DownloadRequest[0]; } InputStream inputStream = null; try { inputStream = atomicFile.openRead(); DataInputStream dataInputStream = new DataInputStream(inputStream); int version = dataInputStream.readInt(); if (version > VERSION) { throw new IOException("Unsupported action file version: " + version); } int actionCount = dataInputStream.readInt(); ArrayList<DownloadRequest> actions = new ArrayList<>(); for (int i = 0; i < actionCount; i++) { try { actions.add(readDownloadRequest(dataInputStream)); } catch (UnsupportedRequestException e) { } } return actions.toArray(new DownloadRequest[0]); } finally { Util.closeQuietly(inputStream); } } }
ActionFile { public DownloadRequest[] load() throws IOException { if (!exists()) { return new DownloadRequest[0]; } InputStream inputStream = null; try { inputStream = atomicFile.openRead(); DataInputStream dataInputStream = new DataInputStream(inputStream); int version = dataInputStream.readInt(); if (version > VERSION) { throw new IOException("Unsupported action file version: " + version); } int actionCount = dataInputStream.readInt(); ArrayList<DownloadRequest> actions = new ArrayList<>(); for (int i = 0; i < actionCount; i++) { try { actions.add(readDownloadRequest(dataInputStream)); } catch (UnsupportedRequestException e) { } } return actions.toArray(new DownloadRequest[0]); } finally { Util.closeQuietly(inputStream); } } ActionFile(File actionFile); }
ActionFile { public DownloadRequest[] load() throws IOException { if (!exists()) { return new DownloadRequest[0]; } InputStream inputStream = null; try { inputStream = atomicFile.openRead(); DataInputStream dataInputStream = new DataInputStream(inputStream); int version = dataInputStream.readInt(); if (version > VERSION) { throw new IOException("Unsupported action file version: " + version); } int actionCount = dataInputStream.readInt(); ArrayList<DownloadRequest> actions = new ArrayList<>(); for (int i = 0; i < actionCount; i++) { try { actions.add(readDownloadRequest(dataInputStream)); } catch (UnsupportedRequestException e) { } } return actions.toArray(new DownloadRequest[0]); } finally { Util.closeQuietly(inputStream); } } ActionFile(File actionFile); boolean exists(); void delete(); DownloadRequest[] load(); }
ActionFile { public DownloadRequest[] load() throws IOException { if (!exists()) { return new DownloadRequest[0]; } InputStream inputStream = null; try { inputStream = atomicFile.openRead(); DataInputStream dataInputStream = new DataInputStream(inputStream); int version = dataInputStream.readInt(); if (version > VERSION) { throw new IOException("Unsupported action file version: " + version); } int actionCount = dataInputStream.readInt(); ArrayList<DownloadRequest> actions = new ArrayList<>(); for (int i = 0; i < actionCount; i++) { try { actions.add(readDownloadRequest(dataInputStream)); } catch (UnsupportedRequestException e) { } } return actions.toArray(new DownloadRequest[0]); } finally { Util.closeQuietly(inputStream); } } ActionFile(File actionFile); boolean exists(); void delete(); DownloadRequest[] load();  }