What is the setProperty method of the System class for on Android?

Asked

Viewed 1,941 times

3

In my case I used so:

System.setProperty("file.encoding", "UTF-8");

It would be the identification of the language used?

1 answer

3

When you run a program you "start" a JVM instance and this instance has its own environment variables, some properties being initialized natively (native method initProperties). In the implementation of System you notice that there is a static variable of Properties, which is the object that contains all system properties and is accessible by any application/library running on the instance of JVM.

Of the documentation of System.setProperty

Sets the system Property indicated by the specified key.

That is, this method creates or changes the value of a system property that is shared by all applications/libraries running on the same instance of JVM.

In your case you are redefining the encoding (encoding) default to be used by applications/libraries running in the same instance you are running your application.

Just as a curiosity about coding in the JVM, there are three encodings "pattern":

Browser other questions tagged

You are not signed in. Login or sign up in order to post.