Tabnine Logo
IOUtil.getResourceAsStream
Code IndexAdd Tabnine to your IDE (free)

How to use
getResourceAsStream
method
in
org.identityconnectors.common.IOUtil

Best Java code snippets using org.identityconnectors.common.IOUtil.getResourceAsStream (Showing top 9 results out of 315)

origin: Tirasa/ConnId

/**
 * Extracts the resource to a file.
 *
 * @param clazz
 * The class, relative to which path is resolved
 * @param path
 * The path to the resource
 * @param file
 * The file to extract to
 * @throws IOException
 * If an error occurs reading it
 */
public static void extractResourceToFile(final Class<?> clazz, final String path,
    final File file) throws IOException {
  final InputStream in = getResourceAsStream(clazz, path);
  if (in == null) {
    throw new IOException("Missing resource: " + path);
  }
  OutputStream out = null;
  try {
    out = new FileOutputStream(file);
    IOUtil.copyFile(in, out);
  } finally {
    if (out != null) {
      out.close();
    }
    in.close();
  }
}
origin: net.tirasa.connid/connector-framework

/**
 * Extracts the resource to a file.
 *
 * @param clazz
 * The class, relative to which path is resolved
 * @param path
 * The path to the resource
 * @param file
 * The file to extract to
 * @throws IOException
 * If an error occurs reading it
 */
public static void extractResourceToFile(final Class<?> clazz, final String path,
    final File file) throws IOException {
  final InputStream in = getResourceAsStream(clazz, path);
  if (in == null) {
    throw new IOException("Missing resource: " + path);
  }
  OutputStream out = null;
  try {
    out = new FileOutputStream(file);
    IOUtil.copyFile(in, out);
  } finally {
    if (out != null) {
      out.close();
    }
    in.close();
  }
}
origin: org.connid/framework

  String path,
  File file) throws IOException {
InputStream in = getResourceAsStream(clazz, path);
if ( in == null ) {
  throw new IOException("Missing resource: "+path);
origin: org.connid/framework

/**
 * Get the resource as a byte array.
 */
public static byte[] getResourceAsBytes(Class<?> clazz, String res) {
  assert clazz != null && StringUtil.isNotBlank(res);
  // copy bytes from the stream to an array..
  InputStream ins = getResourceAsStream(clazz, res);
  if (ins == null) {
    throw new IllegalStateException("Resource not found: " + res);
  }
  byte[] ret = inputStreamToBytes(ins);
  quietClose(ins);
  return ret;
}
origin: net.tirasa.connid/connector-framework

/**
 * Get the resource as a byte array.
 *
 * @param clazz
 * @param res
 * @return
 */
public static byte[] getResourceAsBytes(final Class<?> clazz, final String res) {
  assert clazz != null && StringUtil.isNotBlank(res);
  // copy bytes from the stream to an array..
  final InputStream ins = getResourceAsStream(clazz, res);
  if (ins == null) {
    throw new IllegalStateException("Resource not found: " + res);
  }
  final byte[] ret = inputStreamToBytes(ins);
  quietClose(ins);
  return ret;
}
origin: org.connid/framework

/**
 * Read the entire stream into a String and return it.
 */
public static String getResourceAsString(Class<?> clazz, String res,
    Charset charset) {
  assert clazz != null && StringUtil.isNotBlank(res);
  String ret = null;
  InputStream ins = getResourceAsStream(clazz, res);
  if (ins != null) {
    try {
      InputStreamReader rdr = new InputStreamReader(ins, charset);
      ret = readerToString(rdr);
    } finally {
      quietClose(ins);
    }
  }
  return ret;
}
origin: Tirasa/ConnId

/**
 * Read the entire stream into a String and return it.
 *
 * @param clazz
 * @param res
 * @param charset
 * @return
 */
public static String getResourceAsString(final Class<?> clazz, final String res, final Charset charset) {
  assert clazz != null && StringUtil.isNotBlank(res);
  String ret = null;
  final InputStream ins = getResourceAsStream(clazz, res);
  if (ins != null) {
    try {
      final InputStreamReader rdr = new InputStreamReader(ins, charset);
      ret = readerToString(rdr);
    } finally {
      quietClose(ins);
    }
  }
  return ret;
}
origin: Tirasa/ConnId

/**
 * Get the resource as a byte array.
 *
 * @param clazz
 * @param res
 * @return
 */
public static byte[] getResourceAsBytes(final Class<?> clazz, final String res) {
  assert clazz != null && StringUtil.isNotBlank(res);
  // copy bytes from the stream to an array..
  final InputStream ins = getResourceAsStream(clazz, res);
  if (ins == null) {
    throw new IllegalStateException("Resource not found: " + res);
  }
  final byte[] ret = inputStreamToBytes(ins);
  quietClose(ins);
  return ret;
}
origin: net.tirasa.connid/connector-framework

/**
 * Read the entire stream into a String and return it.
 *
 * @param clazz
 * @param res
 * @param charset
 * @return
 */
public static String getResourceAsString(final Class<?> clazz, final String res, final Charset charset) {
  assert clazz != null && StringUtil.isNotBlank(res);
  String ret = null;
  final InputStream ins = getResourceAsStream(clazz, res);
  if (ins != null) {
    try {
      final InputStreamReader rdr = new InputStreamReader(ins, charset);
      ret = readerToString(rdr);
    } finally {
      quietClose(ins);
    }
  }
  return ret;
}
org.identityconnectors.commonIOUtilgetResourceAsStream

Javadoc

Returns an input stream of the resource specified.

Popular methods of IOUtil

  • quietClose
    Quietly closes the statement. This avoids having to handle exceptions, and then inside of the except
  • copyFile
    Copies one file to another. NOTE: does not close streams.
  • loadPropertiesFile
    Attempt to load file based on a string base filename.
  • getResourceAsString
    Read the entire stream into a String and return it.
  • readInputStreamBytes
    Reads an entire file and returns the bytes.
  • readerToString
    Takes a 'Reader' and returns the contents as a string.
  • checksum
    Calculates the CRC32 checksum of the specified file.
  • delete
    Recursively delete all the files in a directory and the directory.
  • extractResourceToFile
    Extracts the resource to a file.
  • getResourceAsProperties
    Loads the given resource as a properties object.
  • getResourcePath
    Get the path to a resource base on the package of given class.
  • inputStreamToBytes
    Takes a 'InputStream' and returns a byte array.
  • getResourcePath,
  • inputStreamToBytes,
  • readFileBytes,
  • storePropertiesFile,
  • makeURL

Popular in Java

  • Reading from database using SQL prepared statement
  • setContentView (Activity)
  • onCreateOptionsMenu (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now