ICU-5886 fix loading under security manager
X-SVN-Rev: 22588
This commit is contained in:
parent
b5fe986e6c
commit
0e5530bc47
@ -7,14 +7,21 @@
|
|||||||
|
|
||||||
package com.ibm.icu.impl.duration.impl;
|
package com.ibm.icu.impl.duration.impl;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.MissingResourceException;
|
||||||
|
import java.util.zip.DataFormatException;
|
||||||
|
|
||||||
import java.io.OutputStreamWriter;
|
import com.ibm.icu.impl.ICUData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A PeriodFormatterDataService that serves PeriodFormatterData
|
* A PeriodFormatterDataService that serves PeriodFormatterData
|
||||||
@ -49,11 +56,8 @@ public class ResourceBasedPeriodFormatterDataService
|
|||||||
*/
|
*/
|
||||||
private ResourceBasedPeriodFormatterDataService() {
|
private ResourceBasedPeriodFormatterDataService() {
|
||||||
List localeNames = new ArrayList(); // of String
|
List localeNames = new ArrayList(); // of String
|
||||||
|
InputStream is = ICUData.getRequiredStream(getClass(), PATH + "index.txt");
|
||||||
try {
|
try {
|
||||||
InputStream is = getClass().getResourceAsStream(PATH + "index.txt");
|
|
||||||
if (is == null) {
|
|
||||||
System.err.println("could not load index.txt");
|
|
||||||
} else {
|
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||||
String string = null;
|
String string = null;
|
||||||
while (null != (string = br.readLine())) {
|
while (null != (string = br.readLine())) {
|
||||||
@ -63,10 +67,9 @@ public class ResourceBasedPeriodFormatterDataService
|
|||||||
}
|
}
|
||||||
localeNames.add(string);
|
localeNames.add(string);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (IOException e) {
|
||||||
System.err.println(e.getMessage());
|
System.err.println("IO Error reading index.txt ");
|
||||||
}
|
}
|
||||||
availableLocales = Collections.unmodifiableList(localeNames);
|
availableLocales = Collections.unmodifiableList(localeNames);
|
||||||
}
|
}
|
||||||
@ -94,7 +97,7 @@ public class ResourceBasedPeriodFormatterDataService
|
|||||||
if (ln != null) {
|
if (ln != null) {
|
||||||
String name = PATH + "pfd_" + ln + ".xml";
|
String name = PATH + "pfd_" + ln + ".xml";
|
||||||
try {
|
try {
|
||||||
InputStream is = getClass().getResourceAsStream(name);
|
InputStream is = ICUData.getStream(getClass(), name);
|
||||||
if (is == null) {
|
if (is == null) {
|
||||||
throw new MissingResourceException("no resource named " + name,name,"");
|
throw new MissingResourceException("no resource named " + name,name,"");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user