JDK-4246614 : Can not change the default encoding for InputStreamReader
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1999-06-15
  • Updated: 2001-06-22
  • Resolved: 2001-06-22
Related Reports
Duplicate :  
Relates :  
Description

Name: tb29552			Date: 06/15/99


I change the default encoding :

java -Dfile.encoding=Big5 myclass

But it has no effect on InputStreamReader()
For example,

System.out.println(System.getProperty("file.encoding"));
InputStreamReader in=new InputStreamReader(System.in);
System.out.println(in.getEncoding());

It prints out:

Big5
MS950

my version is:
java version "1.2"
HotSpot VM (1.0fcs, mixed mode, build E)
(Review ID: 84171) 
======================================================================

Comments
WORK AROUND Name: tb29552 Date: 06/15/99 set the default enconding in your program everywhere ======================================================================
11-06-2004

EVALUATION I don't really consider this a bug. The Java default encoding is intended to match the default encoding used by the host operating system, and changing it would likely break a lot of things (file access, clipboard operations, drag and drop, etc.). If an application wants to use other encodings, it should specify them explicitly. The J2SDK tools use a -encoding option for this purpose. But the intended behavior should be documented better. norbert.lindenberg@Eng 1999-06-21 ============================================================================ As per evaluation above: file.encoding property is not modifiable. There are some inconsistencies recorded in bug 4165411 but it should not be relied upon to be modifiable. Ian.Little@Ireland 6/22/2001
22-06-2001