Java操作HDFS Linux 學習篇(二)

2021-08-21 16:19:43 字數 1917 閱讀 2478

}/*上傳檔案*/

public static void upload() throws exception

}

1. configuration獲取hadoop配置檔案的資訊。

2. conf.set("fs.defaultfs","hdfs://lxp:9000/")可以對hadoop的配置檔案("core-site.xml")資訊手動修改,會覆蓋掉從配置檔案中讀取的資訊;

3. filesystem.get(new uri("hdfs://lxp:9000/"),conf,"root"); root使用者為登入linux系統的登入使用者;

public static void download() throws ioexception

/*檢視檔案資訊*/

public static void listfiles() throws ioexception

}

1.  liststatus可以列出檔案和資料夾的資訊

2.  listfiles只可以獲取檔案

/*建立資料夾*/

public static void mkdir() throws ioexception

1.    fs.mkdirs(new path("/ll/xx/pp"));  如果父目錄不存在,也會一起建立。

/*刪除檔案或者資料夾*/

public static void rm() throws ioexception

一、 fs  = filesystem.get(new uri("hdfs://lxp:9000/"),conf,"root");  要與hadoop配置檔案(「」core-site.xml「」)中的主機名相同(使用的ssh遠端連線工具,沒敲命令直接開啟了,偷懶了。。。。)

1.進入到c盤路徑:c:\windows\system32\drivers\etc

2.在hosts檔案末尾新增如下資訊:

192.168.1.220    master

192.168.1.225    no1

192.168.1.226    no2

192.168.1.227    no3

java 檔案操作

複製檔案 param fromfilepath string 目標檔案 param tofilepath string 儲存檔案的路徑 return boolean 複製成功 true 出錯 false public static boolean copyfile string fromfilepa...

java 檔案操作

public class documentutil else else copyfinished this.copyfolder startfile,desfile return copyfinished 顯示目錄下所有檔案ming public static file getdocuments s...

Java 檔案操作

private jfilechooser chooser filenameextensionfilter filter new filenameextensionfilter allowed file txt jar chooser.setfilefilter filter intvalue cho...