FileDocCategorySizeDatePackage
FileUtils.javaAPI DocGlassfish v2 API3548Fri May 04 22:31:06 BST 2007com.sun.appserv.management.util.misc

FileUtils

public final class FileUtils extends Object
The API that should be used to output from a Cmd running within the framework.

Fields Summary
Constructors Summary
private FileUtils()

Methods Summary
public static java.lang.StringfileToString(java.io.File src)

	    return fileToString( src, 32 * 1024 );
	
public static java.lang.StringfileToString(java.io.File src, int readBufferSize)

		final FileReader	in	= new FileReader( src );

		final long  length  = src.length();
		if ( length > 1024 * 1024 * 1024 )
		{
		    throw new IllegalArgumentException();
		}
		
		final char[]	readBuffer	= new char[ readBufferSize ];
		
		final StringBuilder	result	= new StringBuilder( (int)length );
		try
		{
			while ( true )
			{
				final int numRead	= in.read( readBuffer, 0, readBufferSize );
				if ( numRead < 0 )
					break;
				
				result.append( readBuffer, 0, numRead );
			}
		}
		finally
		{
			in.close();
		}
		
		return( result.toString() );
	
public static voidstringToFile(java.lang.String s, java.io.File dest)

		final FileWriter	out	= new FileWriter( dest );
		
		try
		{
			out.write( s );
		}
		finally
		{
			out.close();
		}