org.opcfoundation.ua.utils
Class FileUtil

java.lang.Object
  extended by org.opcfoundation.ua.utils.FileUtil

public class FileUtil
extends Object

FileUtil class.


Constructor Summary
FileUtil()
           
 
Method Summary
static byte[] readFile(File file)
          Reads entire binary file
static byte[] readFile(URL url)
          Reads entire binary file to a byte array
static byte[] readStream(InputStream is)
          Reads entire binary file to a byte array.
static void writeFile(File file, byte[] data)
          Creates and writes a binary file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtil

public FileUtil()
Method Detail

writeFile

public static void writeFile(File file,
                             byte[] data)
                      throws IOException
Creates and writes a binary file

Parameters:
file - file
data - data
Throws:
IOException - on i/o problems

readFile

public static byte[] readFile(File file)
                       throws IOException
Reads entire binary file

Parameters:
file - file
Returns:
contents of binary file
Throws:
IOException - on i/o problems

readFile

public static byte[] readFile(URL url)
                       throws IOException
Reads entire binary file to a byte array

Parameters:
url - a URL object.
Returns:
contents of binary file
Throws:
IOException - on i/o problems

readStream

public static byte[] readStream(InputStream is)
                         throws IOException
Reads entire binary file to a byte array. Note the stream is not closed.

Parameters:
is - input stream
Returns:
contents of the stream
Throws:
IOException - on i/o problems


Copyright © 2018. All rights reserved.