2016-08-02 142 views

回答

1

您需要的文本文件的字符集時,$是基本的ASCII所以它會顯示幾乎總是,在€-symbol例如在ISO-8859-15或UTF-8。 但正如我所說的,它主要取決於正確讀入的文本文件,Java在內部使用UTF-16並將其覆蓋。並且在使用UTF-8輸出時,您是安全的。

+0

我用ISO_8859_1正確地讀我的文本文件後,它加載到一個表。無論如何,不​​幸的是,當我使用UTF-8時,我仍然得不到符號 – Ramses

1

你爲什麼不只是使用語言環境?

import java.text.NumberFormat; 
import java.util.Currency; 
import java.util.Locale; 

public class Main { 

    public static void main(String[] args) { 
     // TODO Auto-generated method stub 
displayCurrency(new Locale("FR","FR")); 
    } 
    static public void displayCurrency(Locale currentLocale) { 

     Double currencyAmount = new Double(9876543.21); 
     Currency currentCurrency = Currency.getInstance(currentLocale); 
     NumberFormat currencyFormatter = 
      NumberFormat.getCurrencyInstance(currentLocale); 

     System.out.println(
      currentLocale.getDisplayName() + ", " + 
      currentCurrency.getDisplayName() + ": " + 
      currencyFormatter.format(currencyAmount)); 
    } 
} 

輸出

French (France), Euro: 9 876 543,21 €