小编Chi*_*rag的帖子

将目录从本地系统复制到hdfs java代码

我尝试使用java代码将目录从本地系统复制到HDFS时遇到问题.我能够移动单个文件,但无法找到一种方法来移动整个目录与子文件夹和文件.任何人都可以帮助我吗?提前致谢.

java hadoop hdfs

9
推荐指数
1
解决办法
2万
查看次数

java.net.ConnectException:通过代理连接时连接超时

我试图从URL下载一个zip文件,并使用java代码将其存储在本地系统中.我也使用系统代理.它无法连接到网址.任何的想法?

public static void main()
{
   try
   {
      long startTime = System.currentTimeMillis();

      System.out.println("Connecting to the url...\n");
      System.setProperty("http.proxyHost", " http://abc.com");
      System.setProperty("http.proxyPort","1111");

      URL url = new URL("http://sourceforge.net/projects/sevenzip/files/7-Zip/9.20/7z920.exe/download?use_mirror=nchc");
      url.openConnection();
      InputStream reader = url.openStream();
      FileOutputStream writer = new FileOutputStream("/home/user/result/apps.zip);
      byte[] buffer = new byte[153600];
      int totalBytesRead = 0;
      int bytesRead = 0;

      System.out.println("Reading ZIP file 150KB blocks at a time.\n");

      while ((bytesRead = reader.read(buffer)) > 0)
      {  
         writer.write(buffer, 0, bytesRead);
         buffer = new byte[153600];
         totalBytesRead += bytesRead;
      }

      long endTime = System.currentTimeMillis();

      System.out.println("Done downloading. …
Run Code Online (Sandbox Code Playgroud)

java url proxy urlconnection download

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

java ×2

download ×1

hadoop ×1

hdfs ×1

proxy ×1

url ×1

urlconnection ×1