Search in sources :

Example 1 with FileFilter

use of org.orcid.core.utils.Classpath.FileFilter in project ORCID-Source by ORCID.

the class PropertyFiles method loadProFiles.

@Before
public void loadProFiles() throws ZipException, IOException {
    // ResourceBundle resources = ResourceBundle.
    FileFilter fF = new FileFilter() {

        public boolean accept(String fileName) {
            return fileName.matches(".*messages[a-zA-Z\\_\\.]*\\.properties$");
        }
    };
    String[] propfiles = Classpath.getClasspathFileNames(fF, true);
    for (String propertiesFile : propfiles) {
        if (!propertiesFile.contains("orcid"))
            continue;
        byte[] encoded = Files.readAllBytes(Paths.get(propertiesFile));
        Charset utf = Charset.forName("UTF-8");
        CharsetDecoder dec = utf.newDecoder();
        dec.onUnmappableCharacter(CodingErrorAction.REPORT);
        String propStr = dec.decode(ByteBuffer.wrap(encoded)).toString();
        Properties prop = new Properties();
        prop.load(new StringReader(propStr));
        pList.add(prop);
    }
}
Also used : CharsetDecoder(java.nio.charset.CharsetDecoder) StringReader(java.io.StringReader) Charset(java.nio.charset.Charset) FileFilter(org.orcid.core.utils.Classpath.FileFilter) Properties(java.util.Properties) Before(org.junit.Before)

Aggregations

StringReader (java.io.StringReader)1 Charset (java.nio.charset.Charset)1 CharsetDecoder (java.nio.charset.CharsetDecoder)1 Properties (java.util.Properties)1 Before (org.junit.Before)1 FileFilter (org.orcid.core.utils.Classpath.FileFilter)1