commons-io examples

本文提供了使用Apache Commons IO库进行多种文件操作的示例代码,包括删除目录、复制目录、移动目录、计算目录大小等功能。

Maven Dependency

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>org.fool.commons-io</groupId>
	<artifactId>commons-io</artifactId>
	<version>1</version>

	<dependencies>
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>2.4</version>
		</dependency>
	</dependencies>

	<build>
		<sourceDirectory>src</sourceDirectory>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.0</version>
				<configuration>
					<source>1.7</source>
					<target>1.7</target>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>

 

delete directory recursively

package org.fool.commons.io;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

/**
 * delete directory recursively
 */
public class DeleteDirectoryRecursive
{
	public static void main(String[] args)
	{
		File directory = new File("C:/temp1");

		try
		{
			// Deletes a directory recursively.
			FileUtils.deleteDirectory(directory);
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
}

 

copy directory with all its contents to another directory

package org.fool.commons.io;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

/**
 * copy directory with all its contents to another directory
 */
public class DirectoryCopy
{
	public static void main(String[] args)
	{
		// An existing directory to copy.
		File srcDir = new File("C:/temp");

		// The destination directory to copy to. This directory
		// doesn't exists and will be created during the copy
		// directory process.
		File destDir = new File("C:/temp1");

		try
		{
			// Copy source directory into destination directory
			// including its child directories and files. When
			// the destination directory is not exists it will
			// be created. This copy process also preserve the
			// date information of the file.
			FileUtils.copyDirectory(srcDir, destDir);
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
}

 

move directory to another directory with its entire contents

package org.fool.commons.io;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

/**
 * move directory to another directory with its entire contents
 */
public class DirectoryMove
{

	public static void main(String[] args)
	{
		File srcDir = new File("C:/temp1");

		File destDir = new File("C:/temp2");

		try
		{
			// Move the source directory to the destination directory.
			// The destination directory must not exists prior to the
			// move process.
			FileUtils.moveDirectory(srcDir, destDir);
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
}

 

calculate directory size

package org.fool.commons.io;

import java.io.File;

import org.apache.commons.io.FileUtils;

/**
 * calculate directory size
 */
public class DirectorySizeExample
{
	public static void main(String[] args)
	{
		// Using FileUtils.sizeOfDirectory() we can calculate
		// the size of a directory including it sub directory
		long size = FileUtils.sizeOfDirectory(new File("C:/temp"));

		System.out.println("Size: " + size + " bytes");
	}
}

 

get free space of a drive or volume

package org.fool.commons.io;

import java.io.IOException;

import org.apache.commons.io.FileSystemUtils;
import org.apache.commons.io.FileUtils;

/**
 * get free space of a drive or volume
 */
public class DiskFreeSpace
{
	public static void main(String[] args)
	{
		try
		{
			String path = "C:";
			long freeSpaceKB = FileSystemUtils.freeSpaceKb(path);
			long freeSpaceMB = freeSpaceKB / FileUtils.ONE_KB;
			long freeSpaceGB = freeSpaceKB / FileUtils.ONE_MB;

			System.out.println("Size of " + path + " = " + freeSpaceKB + " KB");
			System.out.println("Size of " + path + " = " + freeSpaceMB + " MB");
			System.out.println("Size of " + path + " = " + freeSpaceGB + " GB");
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
}

 

create a copy of a file

package org.fool.commons.io;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

/**
 * create a copy of a file
 */
public class FileCopyExample
{
	public static void main(String[] args)
	{
		File source = new File("pom.xml");

		File target = new File("pom-backup.xml");

		File targetDir = new File("C:/temp");

		try
		{
			System.out.println("Copying " + source + " file to " + target);
			FileUtils.copyFile(source, target);

			System.out.println("Copying " + source + " file to " + targetDir);
			FileUtils.copyFileToDirectory(source, targetDir);
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
}

 

sort files base on their last modified date

package org.fool.commons.io;

import java.io.File;
import java.util.Arrays;

import org.apache.commons.io.comparator.LastModifiedFileComparator;

/**
 * sort files base on their last modified date
 */
public class FileSortByLastModified
{
	public static void main(String[] args)
	{
		File dir = new File("C:/temp");

		File[] files = dir.listFiles();

		// Sort files in ascending order base on last modification date.
		Arrays.sort(files, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR);
		for (File file : files)
		{
			System.out.printf("File %s - %2$tm %2$te,%2$tY%n", file.getName(),
					file.lastModified());
		}

		System.out.println();

		// Sort files in descending order base on last modification date.
		Arrays.sort(files, LastModifiedFileComparator.LASTMODIFIED_REVERSE);
		for (File file : files)
		{
			System.out.printf("File %s - %2$tm %2$te,%2$tY%n", file.getName(),
					file.lastModified());
		}
	}
}

 

read a file into byte array

package org.fool.commons.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.io.IOUtils;

/**
 * read a file into byte array
 */
public class FileToByteArray
{
	public static void main(String[] args)
	{
		File file = new File("sample.txt");

		try
		{
			InputStream is = new FileInputStream(file);
			byte[] bytes = IOUtils.toByteArray(is);

			System.out.println("Byte array size: " + bytes.length);
		}
		catch (FileNotFoundException e)
		{
			e.printStackTrace();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
}

 

get the content of an InputStream as a String

package org.fool.commons.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.io.IOUtils;

/**
 * get the content of an InputStream as a String
 */
public class InputStreamToString
{
	public static void main(String[] args)
	{
		InputStream is = null;

		try
		{
			is = new FileInputStream(new File("sample.txt"));
			String contents = IOUtils.toString(is, "UTF-8");
			System.out.println(contents);
		}
		catch (FileNotFoundException e)
		{
			e.printStackTrace();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		finally
		{
			IOUtils.closeQuietly(is);
		}
	}
}

 

create a human-readable file size

package org.fool.commons.io;

import java.io.File;

import org.apache.commons.io.FileUtils;

/**
 * create a human-readable file size
 */
public class ReadableFileSize
{
	public static void main(String[] args)
	{
		File file = new File(
				"C:/TDDOWNLOAD/JavaTools/JDK/jdk-6u38-windows-x64.exe");

		long size = file.length();
		String display = FileUtils.byteCountToDisplaySize(size);

		System.out.println("Name    = " + file.getName());
		System.out.println("size    = " + size);
		System.out.println("Display = " + display);
	}
}

 

read content line by line

package org.fool.commons.io;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.apache.commons.io.FileUtils;

/**
 * read content line by line
 */
public class ReadFileToListSample
{
	public static void main(String[] args)
	{
		File file = new File("sample.txt");

		List<String> contents = null;

		try
		{
			contents = FileUtils.readLines(file);
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}

		for (String line : contents)
		{
			System.out.println(line);
		}
	}
}

 

write string data to file

package org.fool.commons.io;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

/**
 * write string data to file
 */
public class WriteStringToFileExample
{
	public static void main(String[] args)
	{
		File file = new File("sample.txt");

		String data = "Apache Commons IO";

		try
		{
			FileUtils.writeStringToFile(file, data);
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
}

 

read file contents to string

package org.fool.commons.io;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

/**
 * read file contents to string
 */
public class ReadFileToStringExample
{
	public static void main(String[] args)
	{
		File file = new File("sample.txt");

		String data = null;

		try
		{
			data = FileUtils.readFileToString(file);
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}

		System.out.println(data);
	}
}

 

search for files recursively

package org.fool.commons.io;

import java.io.File;
import java.util.Collection;

import org.apache.commons.io.FileUtils;

/**
 * search for files recursively
 */
public class SearchFileRecursive
{
	public static void main(String[] args)
	{
		File root = new File("C:/temp");

		String[] extensions = { "xml", "java", "dat" };
		boolean recursive = true;

		Collection<File> files = FileUtils.listFiles(root, extensions,
				recursive);

		for (File file : files)
		{
			System.out.println("File = " + file.getAbsolutePath());
		}
	}
}

 

touch a file

package org.fool.commons.io;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

/**
 * touch a file
 */
public class TouchFileExample
{
	public static void main(String[] args)
	{
		File file = new File("touch.dat");

		try
		{
			// Touch the file, when the file is not exist a new file will be
			// created. If the file exist change the file timestamp.
			FileUtils.touch(file);
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
}

 

 

STARTUP_MSG: classpath = /opt/programs/hadoop-2.7.6/etc/hadoop:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/commons-compress-1.4.1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/commons-cli-1.2.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/jettison-1.1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/curator-framework-2.7.1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/java-xmlbuilder-0.4.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/slf4j-api-1.7.10.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/commons-digester-1.8.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/httpclient-4.2.5.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/api-asn1-api-1.0.0-M20.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/protobuf-java-2.5.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/jersey-server-1.9.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/mockito-all-1.8.5.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/commons-httpclient-3.1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/jersey-core-1.9.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/xmlenc-0.52.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/jackson-mapper-asl-1.9.13.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/jersey-json-1.9.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/curator-client-2.7.1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/avro-1.7.4.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/commons-net-3.1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/jackson-xc-1.9.13.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/log4j-1.2.17.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/gson-2.2.4.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/hamcrest-core-1.3.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/commons-io-2.4.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/commons-configuration-1.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/activation-1.1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/api-util-1.0.0-M20.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/jets3t-0.9.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/apacheds-i18n-2.0.0-M15.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/jetty-util-6.1.26.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/commons-collections-3.2.2.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/zookeeper-3.4.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/jackson-core-asl-1.9.13.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/commons-beanutils-core-1.8.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/jsch-0.1.54.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/jaxb-impl-2.2.3-1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/commons-math3-3.1.1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/hadoop-auth-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/servlet-api-2.5.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/commons-logging-1.1.3.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/jsr305-3.0.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/commons-beanutils-1.7.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/xz-1.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/jaxb-api-2.2.2.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/jetty-sslengine-6.1.26.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/curator-recipes-2.7.1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/snappy-java-1.0.4.1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/guava-11.0.2.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/hadoop-annotations-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/httpcore-4.2.5.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/junit-4.11.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/jackson-jaxrs-1.9.13.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/paranamer-2.3.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/netty-3.6.2.Final.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/jsp-api-2.1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/asm-3.2.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/stax-api-1.0-2.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/apacheds-kerberos-codec-2.0.0-M15.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/commons-codec-1.4.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/jetty-6.1.26.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/htrace-core-3.1.0-incubating.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/lib/commons-lang-2.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/hadoop-common-2.7.6-tests.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/hadoop-common-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/common/hadoop-nfs-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/xml-apis-1.3.04.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/commons-cli-1.2.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/netty-all-4.0.23.Final.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/protobuf-java-2.5.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/jersey-server-1.9.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/jersey-core-1.9.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/xmlenc-0.52.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/jackson-mapper-asl-1.9.13.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/leveldbjni-all-1.8.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/log4j-1.2.17.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/commons-io-2.4.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/jetty-util-6.1.26.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/jackson-core-asl-1.9.13.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/xercesImpl-2.9.1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/servlet-api-2.5.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/commons-logging-1.1.3.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/jsr305-3.0.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/guava-11.0.2.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/commons-daemon-1.0.13.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/netty-3.6.2.Final.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/asm-3.2.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/commons-codec-1.4.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/jetty-6.1.26.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/htrace-core-3.1.0-incubating.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/lib/commons-lang-2.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/hadoop-hdfs-nfs-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/hadoop-hdfs-2.7.6-tests.jar:/opt/programs/hadoop-2.7.6/share/hadoop/hdfs/hadoop-hdfs-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/commons-compress-1.4.1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/guice-3.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/commons-cli-1.2.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/jettison-1.1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/protobuf-java-2.5.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/jersey-server-1.9.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/jersey-core-1.9.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/jackson-mapper-asl-1.9.13.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/jersey-json-1.9.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/jackson-xc-1.9.13.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/leveldbjni-all-1.8.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/guice-servlet-3.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/log4j-1.2.17.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/commons-io-2.4.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/activation-1.1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/jetty-util-6.1.26.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/commons-collections-3.2.2.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/zookeeper-3.4.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/jersey-guice-1.9.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/jackson-core-asl-1.9.13.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/jaxb-impl-2.2.3-1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/javax.inject-1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/jersey-client-1.9.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/servlet-api-2.5.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/commons-logging-1.1.3.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/jsr305-3.0.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/xz-1.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/jaxb-api-2.2.2.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/guava-11.0.2.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/zookeeper-3.4.6-tests.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/jackson-jaxrs-1.9.13.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/netty-3.6.2.Final.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/asm-3.2.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/stax-api-1.0-2.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/aopalliance-1.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/commons-codec-1.4.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/jetty-6.1.26.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/lib/commons-lang-2.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/hadoop-yarn-server-nodemanager-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/hadoop-yarn-server-common-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/hadoop-yarn-server-resourcemanager-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/hadoop-yarn-server-applicationhistoryservice-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/hadoop-yarn-server-tests-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/hadoop-yarn-common-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/hadoop-yarn-client-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/hadoop-yarn-applications-distributedshell-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/hadoop-yarn-registry-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/hadoop-yarn-server-web-proxy-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/hadoop-yarn-applications-unmanaged-am-launcher-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/hadoop-yarn-server-sharedcachemanager-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/yarn/hadoop-yarn-api-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/commons-compress-1.4.1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/guice-3.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/protobuf-java-2.5.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/jersey-server-1.9.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/jersey-core-1.9.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/jackson-mapper-asl-1.9.13.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/avro-1.7.4.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/leveldbjni-all-1.8.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/guice-servlet-3.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/log4j-1.2.17.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/hamcrest-core-1.3.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/commons-io-2.4.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/jersey-guice-1.9.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/jackson-core-asl-1.9.13.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/javax.inject-1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/xz-1.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/snappy-java-1.0.4.1.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/hadoop-annotations-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/junit-4.11.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/paranamer-2.3.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/netty-3.6.2.Final.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/asm-3.2.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/lib/aopalliance-1.0.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.7.6-tests.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/hadoop-mapreduce-client-common-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-plugins-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/hadoop-mapreduce-client-app-2.7.6.jar:/opt/programs/hadoop-2.7.6/share/hadoop/mapreduce/hadoop-mapreduce-client-shuffle-2.7.6.jar:/opt/programs/hadoop-2.7.6/contrib/capacity-scheduler/*.jar STARTUP_MSG: build = https://shv@git-wip-us.apache.org/repos/asf/hadoop.git -r 085099c66cf28be31604560c376fa282e69282b8; compiled by 'kshvachk' on 2018-04-18T01:33Z STARTUP_MSG: java = 1.8.0_211 ************************************************************/ 25/10/15 06:06:24 INFO server.JournalNode: registered UNIX signal handlers for [TERM, HUP, INT] 25/10/15 06:06:24 INFO impl.MetricsConfig: loaded properties from hadoop-metrics2.properties 25/10/15 06:06:24 INFO impl.MetricsSystemImpl: Scheduled snapshot period at 10 second(s). 25/10/15 06:06:24 INFO impl.MetricsSystemImpl: JournalNode metrics system started 25/10/15 06:06:25 INFO hdfs.DFSUtil: Starting Web-server for journal at: http://0.0.0.0:8480 25/10/15 06:06:25 INFO mortbay.log: Logging to org.slf4j.impl.Log4jLoggerAdapter(org.mortbay.log) via org.mortbay.log.Slf4jLog 25/10/15 06:06:25 INFO server.AuthenticationFilter: Unable to initialize FileSignerSecretProvider, falling back to use random secrets. 25/10/15 06:06:25 INFO http.HttpRequestLog: Http request log for http.requests.journal is not defined 25/10/15 06:06:25 INFO http.HttpServer2: Added global filter 'safety' (class=org.apache.hadoop.http.HttpServer2$QuotingInputFilter) 25/10/15 06:06:25 INFO http.HttpServer2: Added filter static_user_filter (class=org.apache.hadoop.http.lib.StaticUserWebFilter$StaticUserFilter) to context journal 25/10/15 06:06:25 INFO http.HttpServer2: Added filter static_user_filter (class=org.apache.hadoop.http.lib.StaticUserWebFilter$StaticUserFilter) to context static 25/10/15 06:06:25 INFO http.HttpServer2: Added filter static_user_filter (class=org.apache.hadoop.http.lib.StaticUserWebFilter$StaticUserFilter) to context logs 25/10/15 06:06:25 INFO http.HttpServer2: Jetty bound to port 8480 25/10/15 06:06:25 INFO mortbay.log: jetty-6.1.26 25/10/15 06:06:25 INFO mortbay.log: Started HttpServer2$SelectChannelConnectorWithSafeStartup@0.0.0.0:8480 25/10/15 06:06:25 INFO ipc.CallQueueManager: Using callQueue: class java.util.concurrent.LinkedBlockingQueue queueCapacity: 500 25/10/15 06:06:25 INFO ipc.Server: Starting Socket Reader #1 for port 8485 25/10/15 06:06:26 INFO ipc.Server: IPC Server Responder: starting 25/10/15 06:06:26 INFO ipc.Server: IPC Server listener on 8485: starting 怎么解决 没有格式化成功 路径没有错
10-16
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值