Class FileIO

java.lang.Object
jcuda.utils.FileIO

public class FileIO extends Object
File I/O functions, similar to the CUTIL file functions
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Read the contents of the file with the given name, and return it as a String
    static byte[]
    readFileByte(String filename)
    Reads the file with the given name containing byte data, and returns the contents of this file as an array
    static double[]
    Reads the file with the given name containing double precision floating point data, and returns the contents of this file as an array
    static float[]
    Reads the file with the given name containing single precision floating point data, and returns the contents of this file as an array
    static int[]
    readFileInt(String filename)
    Reads the file with the given name containing integer data, and returns the contents of this file as an array
    static void
    writeFile(String filename, byte[] data)
    Writes the given array into a file with the given name.
    static void
    writeFile(String filename, double[] data, double epsilon)
    Writes the given array into a file with the given name.
    static void
    writeFile(String filename, float[] data, float epsilon)
    Writes the given array into a file with the given name.
    static void
    writeFile(String filename, int[] data)
    Writes the given array into a file with the given name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • readFileFloat

      public static float[] readFileFloat(String filename)
      Reads the file with the given name containing single precision floating point data, and returns the contents of this file as an array
      Parameters:
      filename - The name of the file
      Returns:
      The contents of the file
      Throws:
      jcuda.CudaException - if the file could not be read
    • readFileDouble

      public static double[] readFileDouble(String filename)
      Reads the file with the given name containing double precision floating point data, and returns the contents of this file as an array
      Parameters:
      filename - The name of the file
      Returns:
      The contents of the file
      Throws:
      jcuda.CudaException - if the file could not be read
    • readFileInt

      public static int[] readFileInt(String filename)
      Reads the file with the given name containing integer data, and returns the contents of this file as an array
      Parameters:
      filename - The name of the file
      Returns:
      The contents of the file
      Throws:
      jcuda.CudaException - if the file could not be read
    • readFileByte

      public static byte[] readFileByte(String filename)
      Reads the file with the given name containing byte data, and returns the contents of this file as an array
      Parameters:
      filename - The name of the file
      Returns:
      The contents of the file
      Throws:
      jcuda.CudaException - if the file could not be read
    • writeFile

      public static void writeFile(String filename, float[] data, float epsilon)
      Writes the given array into a file with the given name.
      Parameters:
      filename - The name of the file
      data - The data to write
      epsilon - Epsilon for comparison
      Throws:
      jcuda.CudaException - if the file could not be written
    • writeFile

      public static void writeFile(String filename, double[] data, double epsilon)
      Writes the given array into a file with the given name.
      Parameters:
      filename - The name of the file
      data - The data to write
      epsilon - Epsilon for comparison
      Throws:
      jcuda.CudaException - if the file could not be written
    • writeFile

      public static void writeFile(String filename, int[] data)
      Writes the given array into a file with the given name.
      Parameters:
      filename - The name of the file
      data - The data to write
      Throws:
      jcuda.CudaException - if the file could not be written
    • writeFile

      public static void writeFile(String filename, byte[] data)
      Writes the given array into a file with the given name.
      Parameters:
      filename - The name of the file
      data - The data to write
      Throws:
      jcuda.CudaException - if the file could not be written
    • readFileAsString

      public static String readFileAsString(String filename)
      Read the contents of the file with the given name, and return it as a String
      Parameters:
      filename - The name of the file
      Returns:
      The contents of the file
      Throws:
      jcuda.CudaException - If the file could not be read