@Test public void testCopy() throws IOException { PrintWriter writer = new PrintWriter(tmpFilename, "UTF-8"); writer.println("The first line"); writer.println("The second line"); writer.close(); try { assertTrue(hdfsClient.copyLocalToHdfs(tmpFilename, "/tmp", false, true)); assertTrue(hdfsClient.delete(tmpFilename, false)); } catch (HdfsException e) { assertFalse(true); } }
public boolean copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite) throws HdfsException { Path srcPathObj = new Path(srcPath); Path dstPathObj = new Path(dstPath); try { return FileUtil.copy(fileSystem, srcPathObj, fileSystem, dstPathObj, deleteSource, overwrite, fileSystem.getConf()); } catch (IOException e) { LOGGER.error("Copy exception", e); throw new HdfsException("Copy exception", e); } }
HdfsClient implements Closeable { public boolean copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite) throws HdfsException { Path srcPathObj = new Path(srcPath); Path dstPathObj = new Path(dstPath); try { return FileUtil.copy(fileSystem, srcPathObj, fileSystem, dstPathObj, deleteSource, overwrite, fileSystem.getConf()); } catch (IOException e) { LOGGER.error("Copy exception", e); throw new HdfsException("Copy exception", e); } } }
HdfsClient implements Closeable { public boolean copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite) throws HdfsException { Path srcPathObj = new Path(srcPath); Path dstPathObj = new Path(dstPath); try { return FileUtil.copy(fileSystem, srcPathObj, fileSystem, dstPathObj, deleteSource, overwrite, fileSystem.getConf()); } catch (IOException e) { LOGGER.error("Copy exception", e); throw new HdfsException("Copy exception", e); } } private  HdfsClient(Configuration conf); }
HdfsClient implements Closeable { public boolean copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite) throws HdfsException { Path srcPathObj = new Path(srcPath); Path dstPathObj = new Path(dstPath); try { return FileUtil.copy(fileSystem, srcPathObj, fileSystem, dstPathObj, deleteSource, overwrite, fileSystem.getConf()); } catch (IOException e) { LOGGER.error("Copy exception", e); throw new HdfsException("Copy exception", e); } } private  HdfsClient(Configuration conf); static void init(Configuration conf); static HdfsClient getInstance(); void addFile(String fileName, byte[] content, String destPath, boolean isOverwrite); void readFile(String hdfsFile, String localFile, boolean overwrite); byte[] readFile(String hdfsFile); boolean delete(String path, boolean recursive); boolean rename(String path, String destPath); void mkdir(String dir); void mkdir(String dir, FsPermission perm); void setOwner(Path path, String user, String group); void setPermission(Path path, FsPermission perm); void setPermissionThis(Path path, FsPermission perm); boolean copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite); boolean copyLocalToHdfs(String srcPath, String dstPath, boolean deleteSource, boolean overwrite); boolean copyHdfsToLocal(String srcPath, String dstPath, boolean deleteSource, boolean overwrite); long getFileLength(String filePath); boolean exists(String filePath); FileStatus getFileStatus(String filePath); FileStatus[] listFileStatus(String filePath); ContentSummary getContentSummary(String filePath); String getUrl(); @Override void close(); FsStatus getCapacity(); }
HdfsClient implements Closeable { public boolean copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite) throws HdfsException { Path srcPathObj = new Path(srcPath); Path dstPathObj = new Path(dstPath); try { return FileUtil.copy(fileSystem, srcPathObj, fileSystem, dstPathObj, deleteSource, overwrite, fileSystem.getConf()); } catch (IOException e) { LOGGER.error("Copy exception", e); throw new HdfsException("Copy exception", e); } } private  HdfsClient(Configuration conf); static void init(Configuration conf); static HdfsClient getInstance(); void addFile(String fileName, byte[] content, String destPath, boolean isOverwrite); void readFile(String hdfsFile, String localFile, boolean overwrite); byte[] readFile(String hdfsFile); boolean delete(String path, boolean recursive); boolean rename(String path, String destPath); void mkdir(String dir); void mkdir(String dir, FsPermission perm); void setOwner(Path path, String user, String group); void setPermission(Path path, FsPermission perm); void setPermissionThis(Path path, FsPermission perm); boolean copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite); boolean copyLocalToHdfs(String srcPath, String dstPath, boolean deleteSource, boolean overwrite); boolean copyHdfsToLocal(String srcPath, String dstPath, boolean deleteSource, boolean overwrite); long getFileLength(String filePath); boolean exists(String filePath); FileStatus getFileStatus(String filePath); FileStatus[] listFileStatus(String filePath); ContentSummary getContentSummary(String filePath); String getUrl(); @Override void close(); FsStatus getCapacity();  }