(宿題の免責事項) 128 Asciiにはない特殊文字のマップを作成しようとしています。 文字が見つかると、その文字を文字の近くのAsciiに置き換える必要があります。データは特殊文字をASCII文字に置き換えるマップを作成する
例えば
543|Misèrables, Les (1995)
543|Miserables, Les (1995)
のようなテキストを持つファイルから来ている2行目は私が正しく私のマップを使用した後、それがどのように見えるべきかです。
は、ここに私のマップ
Map<Integer, Character> ascMap = new HashMap<>();
//ascMap.put(246, 'o');
//ascMap.put(232, 'e');
ascMap.put('ö' , 'o');
ascMap.put('è' , 'e');
と私のコードの残りの部分です。あなたのマップ宣言で
String newMovieLine = null;
String store = null;
String empty = null;
int movieCount = 0;
int ascCount = 0;
//System.out.println(ascMap);
try {
FileReader readFile = new FileReader(movieFile);
BufferedReader buffMovie = new BufferedReader(readFile);
//read while stream is not empty
while ((empty = buffMovie.readLine()) != null){
if(isAscii(empty) == false){
store = empty;
newMovieLine = empty;
movieCount++;
System.out.println(store); //print each line withnon ascii characters
System.out.println(" ");
}
//check the value for ascii
for(int j = 0, n = empty.length(); j < n; j++){
char asc = empty.charAt(j);
if(asc > 127){
ascCount++;
}
if(asc == 246){
asc = ascMap.get(246);
newMovieLine = newMovieLine.replace('ö' , 'o');
}
else if(asc == 232){
asc = ascMap.get(232);
newMovieLine = newMovieLine.replace('è','e');
}}}
あなたの質問は何ですか? –
現在のバージョンは文字を置き換えません。だから私の質問は何が間違っているのですか?私はif文で特殊文字を232に置き換えましたが、結果はありません。私は無数のことをしましたが、私は何をすべきか分かりません。 – akrutke