Example usage for org.apache.ibatis.io Resources getResourceAsFile

List of usage examples for org.apache.ibatis.io Resources getResourceAsFile

Introduction

In this page you can find the example usage for org.apache.ibatis.io Resources getResourceAsFile.

Prototype

public static File getResourceAsFile(String resource) throws IOException 

Source Link

Document

Returns a resource on the classpath as a File object

Usage

From source file:Clases.ConsultaMedica.java

public static void main(String[] args) {
    try {/* ww  w  .  j  a va 2  s  . c  o m*/
        File archivo = Resources.getResourceAsFile("configuracion.properties");
        System.out.println(archivo.toString());
        Properties properties = Resources.getResourceAsProperties("configuracion.properties");
        System.out.println(properties.getProperty("directorio"));

    } catch (IOException ex) {
        Logger.getLogger(ConsultaMedica.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.oneops.cms.util.CmsUtilTest.java

License:Apache License

public CmsUtilTest() {
    this.ciAttributes = new HashMap<>(3);
    this.ciAttributes.put("A", "1");
    this.ciAttributes.put("B", "2");
    this.ciAttributes.put("Z", "26");

    this.ciSimple.setCiClassName(CLASS_NAME);
    this.ciSimple.setCiId(CI_ID);
    this.ciSimple.setCiName(CI_NAME);
    this.ciSimple.setCreated(new Date());
    this.ciSimple.setImpl(CI_IMPL);
    this.ciSimple.setNsPath(NS_PATH);
    this.ciSimple.setCiAttributes(ciAttributes);

    try {/*w ww  . j a  va2s  .  c o  m*/
        String resource = "cloud_system_vars.json";
        String flavorVars = new Scanner(Resources.getResourceAsFile(resource)).useDelimiter("\\Z").next();

        cmsCmProcessor = Mockito.mock(CmsCmProcessor.class);

        cmsVarProviderMapping = new CmsVar();

        cmsVarProviderMapping.setValue(flavorVars);

    } catch (Exception e) {
        System.out.println(e);
    }
}

From source file:fr.cph.stock.language.LanguageFactory.java

License:Apache License

/**
 * Get the language map//from www .j a v a 2s.  c  om
 * 
 * @return the language map
 * @throws LanguageException
 *             the language exception
 */
private static Map<String, Map<String, String>> getLanguageMap() throws LanguageException {
    Map<String, Map<String, String>> m = new HashMap<String, Map<String, String>>();
    File file = null;
    try {
        file = Resources.getResourceAsFile("fr" + system.getSeparator() + "cph" + system.getSeparator()
                + "stock" + system.getSeparator() + "language" + system.getSeparator() + "xml");
    } catch (IOException e) {
        throw new LanguageException(e.getMessage(), e);
    }
    if (file.isDirectory()) {
        List<File> files = Arrays.asList(file.listFiles());
        for (File f : files) {
            String absolutPath = f.getAbsolutePath();
            String path = absolutPath.substring(absolutPath.indexOf("fr" + system.getSeparator() + "cph"
                    + system.getSeparator() + "stock" + system.getSeparator() + "language"
                    + system.getSeparator() + "xml" + system.getSeparator()), absolutPath.length());
            Language language = new Language(path);
            m.put(language.getLanguageName(), language.getLanguage());
        }
    }
    return m;
}