![JAR search and dependency download from the Maven repository](/logo.png)
com.github.powerlibraries.io.IOConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of iopower Show documentation
Show all versions of iopower Show documentation
Power Libraries is a small project to collect some repeatedly needed or otherwise useful Java 8 classes in a collection of tiny libraries.
IO Power is the first and really tiny library of the Power Libraries. It contains some simple helper method for opening Input- and Outputstreams. The main purpose of IO Power is to make opening streams, readers and writers less cluttered and simple to understand.
The newest version!
package com.github.powerlibraries.io;
import java.nio.charset.Charset;
import java.nio.charset.UnsupportedCharsetException;
/**
* This class contains static constants used by IO Power.
* @author Manuel Hegner
*
*/
public final class IOConfig {
/**
* There is no reason to create an instance.
*/
private IOConfig() {}
private static Charset DEFAULT_CHARSET=Charset.defaultCharset();
/**
* This method returns the default charset that is used by all In and OutBuilders.
* By default this method returns the platform default charset returned by
* {@link Charset#defaultCharset()}.
* @return the default charset that is used by IOPower classes.
*/
public static Charset getDefaultCharset() {
return DEFAULT_CHARSET;
}
/**
* This method sets the default {@link Charset} that is used by all In and OutBuilders.
* By default this is the platform default charset returned by
* {@link Charset#defaultCharset()}.
* @param charset the {@link Charset} that should be used by default
*/
public static void setDefaultCharset(Charset charset) {
if(charset==null)
throw new NullPointerException("charset can not be null");
DEFAULT_CHARSET=charset;
}
/**
* This method sets the default {@link Charset} that is used by all In and OutBuilders
* by calling {@link Charset#forName(String)} on the given name.
* By default this is the platform default charset returned by
* {@link Charset#defaultCharset()}.
* @param charsetName the name of a {@link Charset} that should be used by default
* @throws UnsupportedCharsetException if no support for the named charset is
* available in this instance of the Java virtual machine
*/
public static void setDefaultCharset(String charsetName) throws UnsupportedCharsetException{
DEFAULT_CHARSET=Charset.forName(charsetName);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy