Package es.gob.afirma.utils
Class UtilsFileSystem
- java.lang.Object
-
- es.gob.afirma.utils.UtilsFileSystem
-
public final class UtilsFileSystem extends java.lang.ObjectUtility class for reading and processing files.
Project:Library for the integration with the services of @Firma, eVisor and TS@.
- Version:
- 1.2, 14/03/2017.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]getArrayByteFileBase64Encoded(java.lang.String path, boolean isRelativePath)Reads a file from system by given path (absolute or relative to classpath) and encodes to Base64 format.static java.lang.StringgetFileBase64Encoded(byte[] content)Method that obtains a String encoded on Base64 from the content of a file.static byte[]readFile(java.lang.String path, boolean isRelativePath)Reads a file from system by given path (absolute or relative to classpath).static java.lang.StringreadFileBase64Encoded(java.lang.String path, boolean isRelativePath)Reads a file from system by given path (absolute or relative to classpath) and encodes to Base64 format.static byte[]readFileFromFileSystemBase64Encoded(java.lang.String filePathToRead)Retrieves encoded Base64 file content.static voidwriteFile(byte[] data, java.lang.String filename)Write data into a file.
-
-
-
Method Detail
-
readFileFromFileSystemBase64Encoded
public static byte[] readFileFromFileSystemBase64Encoded(java.lang.String filePathToRead)
Retrieves encoded Base64 file content. If file would be encoded it'll be returned without encoded.- Parameters:
filePathToRead- absolute file path.- Returns:
- Base64 file content.
-
readFileBase64Encoded
public static java.lang.String readFileBase64Encoded(java.lang.String path, boolean isRelativePath)Reads a file from system by given path (absolute or relative to classpath) and encodes to Base64 format.- Parameters:
path- file path.isRelativePath- true if path is relative to classpath and false if path is absolute.- Returns:
- content file encoded in base64. Returns a null value if an error happens
-
getFileBase64Encoded
public static java.lang.String getFileBase64Encoded(byte[] content)
Method that obtains a String encoded on Base64 from the content of a file.- Parameters:
content- Parameter that represents the content of a file.- Returns:
- the encoded Base64 String.
-
getArrayByteFileBase64Encoded
public static byte[] getArrayByteFileBase64Encoded(java.lang.String path, boolean isRelativePath)Reads a file from system by given path (absolute or relative to classpath) and encodes to Base64 format.- Parameters:
path- file path.isRelativePath- true if path is relative to classpath and false if path is absolute.- Returns:
- content file encoded in base64. Returns a null value if an error happens
-
readFile
public static byte[] readFile(java.lang.String path, boolean isRelativePath)Reads a file from system by given path (absolute or relative to classpath).- Parameters:
path- file path.isRelativePath- true if path is relative to classpath and false if path is absolute.- Returns:
- content file. Returns a null value if an error happens
-
writeFile
public static void writeFile(byte[] data, java.lang.String filename) throws java.io.IOExceptionWrite data into a file. If file doesn't exist, it is created.- Parameters:
data- information to include into file.filename- name of file to record.- Throws:
java.io.IOException- if a error happens accessing to file.
-
-