Package org.hl7.fhir.utilities
Class TextFile
- java.lang.Object
-
- org.hl7.fhir.utilities.TextFile
-
-
Constructor Summary
Constructors Constructor Description TextFile()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidappendBytesToFile(byte[] bytes, String path)static voidbytesToFile(byte[] bytes, File f)static voidbytesToFile(byte[] bytes, String path)static StringbytesToString(byte[] bs)static StringbytesToString(byte[] bs, boolean removeBOM)static byte[]fileToBytes(File file)static byte[]fileToBytes(String srcFile)static byte[]fileToBytesNCS(String srcFile)fileToBytes insists in case correctness to ensure that stuff works across linux and windows, but it's not always appropriate to ceheck case (e.g.static StringfileToString(File f)static StringfileToString(String src)static List<String>readAllLines(String path)static byte[]streamToBytes(InputStream input)static byte[]streamToBytesNoClose(InputStream input)static voidstreamToFile(InputStream stream, String filename)static voidstreamToFileNoClose(InputStream stream, String filename)static StringstreamToString(InputStream input)static byte[]stringToBytes(String content, boolean bom)static voidstringToFile(String content, File file)static voidstringToFile(String content, File file, boolean bom)static voidstringToFile(String content, String path)static voidstringToFile(String content, String path, boolean bom)static voidstringToFileNoPrefix(String content, String path)static voidstringToStream(String content, OutputStream stream, boolean bom)static voidwriteAllLines(String path, List<String> lines)
-
-
-
Constructor Detail
-
TextFile
public TextFile()
-
-
Method Detail
-
readAllLines
public static List<String> readAllLines(String path) throws IOException
- Throws:
IOException
-
writeAllLines
public static void writeAllLines(String path, List<String> lines) throws IOException
- Throws:
IOException
-
stringToFile
public static void stringToFile(String content, File file) throws IOException
- Throws:
IOException
-
stringToStream
public static void stringToStream(String content, OutputStream stream, boolean bom) throws IOException
- Throws:
IOException
-
stringToBytes
public static byte[] stringToBytes(String content, boolean bom) throws IOException
- Throws:
IOException
-
stringToFile
public static void stringToFile(String content, String path) throws IOException
- Throws:
IOException
-
stringToFile
public static void stringToFile(String content, File file, boolean bom) throws IOException
- Throws:
IOException
-
stringToFile
public static void stringToFile(String content, String path, boolean bom) throws IOException
- Throws:
IOException
-
stringToFileNoPrefix
public static void stringToFileNoPrefix(String content, String path) throws IOException
- Throws:
IOException
-
fileToString
public static String fileToString(File f) throws FileNotFoundException, IOException
- Throws:
FileNotFoundExceptionIOException
-
fileToString
public static String fileToString(String src) throws FileNotFoundException, IOException
- Throws:
FileNotFoundExceptionIOException
-
streamToString
public static String streamToString(InputStream input) throws IOException
- Throws:
IOException
-
streamToBytes
public static byte[] streamToBytes(InputStream input) throws IOException
- Throws:
IOException
-
streamToBytesNoClose
public static byte[] streamToBytesNoClose(InputStream input) throws IOException
- Throws:
IOException
-
bytesToFile
public static void bytesToFile(byte[] bytes, String path) throws IOException
- Throws:
IOException
-
bytesToFile
public static void bytesToFile(byte[] bytes, File f) throws IOException
- Throws:
IOException
-
appendBytesToFile
public static void appendBytesToFile(byte[] bytes, String path) throws IOException
- Throws:
IOException
-
fileToBytes
public static byte[] fileToBytes(String srcFile) throws FileNotFoundException, IOException
- Throws:
FileNotFoundExceptionIOException
-
fileToBytesNCS
public static byte[] fileToBytesNCS(String srcFile) throws FileNotFoundException, IOException
fileToBytes insists in case correctness to ensure that stuff works across linux and windows, but it's not always appropriate to ceheck case (e.g. validator parameters)- Parameters:
srcFile-- Returns:
- Throws:
FileNotFoundExceptionIOException
-
fileToBytes
public static byte[] fileToBytes(File file) throws FileNotFoundException, IOException
- Throws:
FileNotFoundExceptionIOException
-
bytesToString
public static String bytesToString(byte[] bs) throws IOException
- Throws:
IOException
-
bytesToString
public static String bytesToString(byte[] bs, boolean removeBOM) throws IOException
- Throws:
IOException
-
streamToFile
public static void streamToFile(InputStream stream, String filename) throws IOException
- Throws:
IOException
-
streamToFileNoClose
public static void streamToFileNoClose(InputStream stream, String filename) throws IOException
- Throws:
IOException
-
-