1 import java.io.*; 2 import org.apache.hadoop.conf.Configuration; 3 import org.apache.hadoop.fs.*; 4 5 public class C_ReadFile { 6 public static void main(String[] args) { 7 try { 8 Var_init var = new Var_init(); 9 var.in = var.fs.open(var.p_remoteFilePath); 10 BufferedReader d = new BufferedReader(new InputStreamReader(var.in)); 11 String line; 12 while ((line = d.readLine()) != null) { 13 System.out.println(line); 14 } 15 System.out.println("read successfully"); 16 } catch (Exception e) { 17 e.printStackTrace(); 18 } 19 } 20 }
Var_init类参考 https://www.cnblogs.com/MiraculousB/p/13848744.html