77范文网 - 专业文章范例文档资料分享平台

hadoop单机部署、集群部署及win7本地Eclipse远程配置管理(6)

来源:网络收集 时间:2019-06-05 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

}

private static Path checkDest(String srcName, FileSystem dstFS, Path dst, boolean overwrite) throws IOException { if (dstFS.exists(dst)) {

FileStatus sdst = dstFS.getFileStatus(dst); if (sdst.isDir()) { if (null == srcName) {

throw new IOException(\ }

return checkDest(null, dstFS, new Path(dst, srcName), overwrite); } else if (!overwrite) {

throw new IOException(\ }

} else if (dst.toString().isEmpty()) {

return checkDest(null, dstFS, new Path(srcName), overwrite); }

return dst; } /**

* This class is only used on windows to invoke the cygpath command. */

private static class CygPathCommand extends Shell { String[] command; String result;

CygPathCommand(String path) throws IOException { command = new String[]{\ run(); }

String getResult() throws IOException { return result; }

protected String[] getExecString() { return command;

}

protected void parseExecResult(BufferedReader lines) throws IOException { String line = lines.readLine(); if (line == null) {

throw new IOException(\ \ }

result = line; } } /**

* Convert a os-native filename to a path that works for the shell. * @param filename The filename to convert * @return The unix pathname

* @throws IOException on windows, there can be problems with the subprocess */

public static String makeShellPath(String filename) throws IOException { if (Path.WINDOWS) {

return new CygPathCommand(filename).getResult(); } else {

return filename; } } /**

* Convert a os-native filename to a path that works for the shell. * @param file The filename to convert * @return The unix pathname

* @throws IOException on windows, there can be problems with the subprocess */

public static String makeShellPath(File file) throws IOException { return makeShellPath(file, false); }

/**

* Convert a os-native filename to a path that works for the shell. * @param file The filename to convert * @param makeCanonicalPath

* Whether to make canonical path for the file passed * @return The unix pathname

* @throws IOException on windows, there can be problems with the subprocess */

public static String makeShellPath(File file, boolean makeCanonicalPath) throws IOException { if (makeCanonicalPath) {

return makeShellPath(file.getCanonicalPath()); } else {

return makeShellPath(file.toString()); } } /**

* Takes an input dir and returns the du on that local directory. Very basic * implementation. *

* @param dir

* The input dir to get the disk space of this local dir * @return The total disk space of the input local directory */

public static long getDU(File dir) { long size = 0; if (!dir.exists()) return 0;

if (!dir.isDirectory()) { return dir.length(); } else {

File[] allFiles = dir.listFiles(); if(allFiles != null) {

for (int i = 0; i < allFiles.length; i++) {

boolean isSymLink; try {

isSymLink = org.apache.commons.io.FileUtils.isSymlink(allFiles[i]); } catch(IOException ioe) { isSymLink = true; }

if(!isSymLink) {

size += getDU(allFiles[i]); } } }

return size; } } /**

* Given a File input it will unzip the file in a the unzip directory * passed as the second parameter * @param inFile The zip file as input

* @param unzipDir The unzip directory where to unzip the zip file. * @throws IOException */

public static void unZip(File inFile, File unzipDir) throws IOException { Enumeration entries; ZipFile zipFile = new ZipFile(inFile); try {

entries = zipFile.entries();

while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); if (!entry.isDirectory()) {

InputStream in = zipFile.getInputStream(entry); try {

File file = new File(unzipDir, entry.getName()); if (!file.getParentFile().mkdirs()) {

if (!file.getParentFile().isDirectory()) {

throw new IOException(\ file.getParentFile().toString()); } }

OutputStream out = new FileOutputStream(file); try {

byte[] buffer = new byte[8192]; int i;

while ((i = in.read(buffer)) != -1) { out.write(buffer, 0, i); } } finally { out.close(); } } finally { in.close(); } } } } finally { zipFile.close(); } } /**

* Given a Tar File as input it will untar the file in a the untar directory * passed as the second parameter *

* This utility will untar \ *

* @param inFile The tar file as input.

* @param untarDir The untar directory where to untar the tar file. * @throws IOException */

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库hadoop单机部署、集群部署及win7本地Eclipse远程配置管理(6)在线全文阅读。

hadoop单机部署、集群部署及win7本地Eclipse远程配置管理(6).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/650579.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: