@Test public void testGetFile() throws Exception { FsWorker worker = createWorker(); String[] testFiles = createTestFiles(); byte[] bytes = worker.get(new File(baseDir, testFiles[0])); assertEquals(DATA, new String(bytes)); try { worker.get(new File(baseUrl.getPath() + "/whatever.txt")); fail("non-existent file didn't throw Exception"); } catch (FsException e) { } try { worker.get(new File(baseUrl.getPath())); fail("directory didn't throw Exception"); } catch (FsException e) { } }
public byte[] get(File file) throws FsException { byte[] result = null; try (RandomAccessFile raf = new RandomAccessFile(checkWriteable(file), "r")) { result = new byte[(int) raf.length()]; raf.readFully(result); } catch (Exception e) { throw wrapException(e); } return result; }
StandardWorker implements FsWorker { public byte[] get(File file) throws FsException { byte[] result = null; try (RandomAccessFile raf = new RandomAccessFile(checkWriteable(file), "r")) { result = new byte[(int) raf.length()]; raf.readFully(result); } catch (Exception e) { throw wrapException(e); } return result; } }
StandardWorker implements FsWorker { public byte[] get(File file) throws FsException { byte[] result = null; try (RandomAccessFile raf = new RandomAccessFile(checkWriteable(file), "r")) { result = new byte[(int) raf.length()]; raf.readFully(result); } catch (Exception e) { throw wrapException(e); } return result; }  }
StandardWorker implements FsWorker { public byte[] get(File file) throws FsException { byte[] result = null; try (RandomAccessFile raf = new RandomAccessFile(checkWriteable(file), "r")) { result = new byte[(int) raf.length()]; raf.readFully(result); } catch (Exception e) { throw wrapException(e); } return result; }  byte[] get(File file); void put(byte[] data, File file); }
StandardWorker implements FsWorker { public byte[] get(File file) throws FsException { byte[] result = null; try (RandomAccessFile raf = new RandomAccessFile(checkWriteable(file), "r")) { result = new byte[(int) raf.length()]; raf.readFully(result); } catch (Exception e) { throw wrapException(e); } return result; }  byte[] get(File file); void put(byte[] data, File file);  }