本文整理了Java中java.io.InputStreamReader.getEncoding()
方法的一些代码示例,展示了InputStreamReader.getEncoding()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。InputStreamReader.getEncoding()
方法的具体详情如下:
包路径:java.io.InputStreamReader
类名称:InputStreamReader
方法名:getEncoding
[英]Returns the canonical name of the encoding used by this writer to convert characters to bytes, or null if this writer has been closed. Most callers should probably keep track of the String or Charset they passed in; this method may not return the same name.
[中]返回此写入程序用于将字符转换为字节的编码的规范名称,如果此写入程序已关闭,则返回null。大多数调用者可能应该跟踪他们传入的字符串或字符集;此方法可能不会返回相同的名称。
代码示例来源:origin: redisson/redisson
/**
* Get stream encoding or NULL if stream is uninitialized. Call init() or
* read() method to initialize it.
* @return the name of the character encoding being used by this stream.
*/
public String getEncoding() {
return internalIn2.getEncoding();
}
代码示例来源:origin: FudanNLP/fnlp
/**
* Get stream encoding or NULL if stream is uninitialized.
* Call init() or read() method to initialize it.
*/
public String getEncoding() {
if (internalIn2 == null) return null;
return internalIn2.getEncoding();
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
/**
* @see InputStreamReader#getEncoding()
* @since 1.3
*/
public String getEncoding() {
return reader.getEncoding();
}
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
/**
* Get stream encoding or NULL if stream is uninitialized. Call init() or
* read() method to initialize it.
* @return the name of the character encoding being used by this stream.
*/
public String getEncoding() {
return internalIn2.getEncoding();
}
代码示例来源:origin: org.apache.ant/ant
/**
* Get the default encoding.
* This is done by opening an InputStreamReader on
* a dummy InputStream and getting the encoding.
* Could use System.getProperty("file.encoding"), but cannot
* see where this is documented.
* @return the default file encoding.
*/
public String getDefaultEncoding() {
InputStreamReader is = new InputStreamReader(
new InputStream() { //NOSONAR
@Override
public int read() {
return -1;
}
});
try {
return is.getEncoding();
} finally {
close(is);
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static final String getLine( LogChannelInterface log, InputStreamReader reader, int formatNr,
StringBuilder line ) throws KettleFileException {
EncodingType type = EncodingType.guessEncodingType( reader.getEncoding() );
return getLine( log, reader, type, formatNr, line );
}
代码示例来源:origin: pentaho/pentaho-kettle
public static final String getLine( LogChannelInterface log, InputStreamReader reader, int formatNr,
StringBuilder line ) throws KettleFileException {
EncodingType type = EncodingType.guessEncodingType( reader.getEncoding() );
return getLine( log, reader, type, formatNr, line );
}
代码示例来源:origin: stackoverflow.com
return reader.getEncoding();
代码示例来源:origin: stackoverflow.com
return reader.getEncoding();
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Creates a new dialog that will handle the wait while we're finding out what tables, views etc we can reach in the
* database.
*/
public TextFileCSVImportProgressDialog( Shell shell, InputFileMetaInterface meta, TransMeta transMeta,
InputStreamReader reader, int samples, boolean replaceMeta ) {
this.shell = shell;
this.meta = meta;
this.reader = reader;
this.samples = samples;
this.replaceMeta = replaceMeta;
this.transMeta = transMeta;
message = null;
debug = "init";
rownumber = 1L;
this.log = new LogChannel( transMeta );
this.encodingType = EncodingType.guessEncodingType( reader.getEncoding() );
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Creates a new dialog that will handle the wait while we're finding out what tables, views etc we can reach in the
* database.
*/
public TextFileCSVImportProgressDialog( Shell shell, TextFileInputMeta meta, TransMeta transMeta,
InputStreamReader reader, int samples, boolean replaceMeta ) {
this.shell = shell;
this.meta = meta;
this.reader = reader;
this.samples = samples;
this.replaceMeta = replaceMeta;
this.transMeta = transMeta;
message = null;
debug = "init";
rownumber = 1L;
this.log = new LogChannel( transMeta );
this.encodingType = EncodingType.guessEncodingType( reader.getEncoding() );
}
代码示例来源:origin: oracle/opengrok
@Override
public void analyze(Document doc, StreamSource src, Writer xrefOut) throws IOException {
try (Reader r = getReader(src.getStream())) {
encoding = ((InputStreamReader) r).getEncoding();
StringBuilder sb = new StringBuilder();
int c;
while ((c = r.read()) != -1) {
sb.append((char) c);
}
contents = sb.toString();
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public TextFileInputReader( IBaseFileInputStepControl step, TextFileInputMeta meta, TextFileInputData data,
FileObject file, LogChannelInterface log ) throws Exception {
this.step = step;
this.meta = meta;
this.data = data;
this.log = log;
CompressionProvider provider =
CompressionProviderFactory.getInstance().getCompressionProviderByName( meta.content.fileCompression );
if ( log.isDetailed() ) {
log.logDetailed( "This is a compressed file being handled by the " + provider.getName() + " provider" );
}
in = provider.createInputStream( KettleVFS.getInputStream( file ) );
in.nextEntry();
BufferedInputStream inStream = new BufferedInputStream( in, BUFFER_SIZE_INPUT_STREAM );
BOMDetector bom = new BOMDetector( inStream );
if ( bom.bomExist() ) {
// if BOM exist, use it instead defined charset
isr = new InputStreamReader( inStream, bom.getCharset() );
} else if ( meta.getEncoding() != null && meta.getEncoding().length() > 0 ) {
isr = new InputStreamReader( inStream, meta.getEncoding() );
} else {
isr = new InputStreamReader( inStream );
}
String encoding = isr.getEncoding();
data.encodingType = EncodingType.guessEncodingType( encoding );
readInitial();
}
代码示例来源:origin: pentaho/pentaho-kettle
final String enclosure = getTransMeta().environmentSubstitute( meta.getEnclosure() );
final EncodingType encodingType = EncodingType.guessEncodingType( reader.getEncoding() );
代码示例来源:origin: pentaho/pentaho-kettle
reader = new InputStreamReader( f );
EncodingType encodingType = EncodingType.guessEncodingType( reader.getEncoding() );
代码示例来源:origin: pentaho/pentaho-kettle
String[] readFieldNamesFromFile( String fileName, CsvInputMeta csvInputMeta ) throws KettleException {
String delimiter = environmentSubstitute( csvInputMeta.getDelimiter() );
String enclosure = environmentSubstitute( csvInputMeta.getEnclosure() );
String realEncoding = environmentSubstitute( csvInputMeta.getEncoding() );
try ( FileObject fileObject = KettleVFS.getFileObject( fileName, getTransMeta() );
BOMInputStream inputStream =
new BOMInputStream( KettleVFS.getInputStream( fileObject ), ByteOrderMark.UTF_8, ByteOrderMark.UTF_16LE,
ByteOrderMark.UTF_16BE ) ) {
InputStreamReader reader = null;
if ( Utils.isEmpty( realEncoding ) ) {
reader = new InputStreamReader( inputStream );
} else {
reader = new InputStreamReader( inputStream, realEncoding );
}
EncodingType encodingType = EncodingType.guessEncodingType( reader.getEncoding() );
String line =
TextFileInput.getLine( log, reader, encodingType, TextFileInputMeta.FILE_FORMAT_UNIX, new StringBuilder(
1000 ) );
String[] fieldNames =
CsvInput.guessStringsFromLine( log, line, delimiter, enclosure, csvInputMeta.getEscapeCharacter() );
if ( !Utils.isEmpty( csvInputMeta.getEnclosure() ) ) {
removeEnclosure( fieldNames, csvInputMeta.getEnclosure() );
}
trimFieldNames( fieldNames );
return fieldNames;
} catch ( IOException e ) {
throw new KettleFileException( BaseMessages.getString( PKG, "CsvInput.Exception.CreateFieldMappingError" ), e );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
reader = new InputStreamReader( f );
EncodingType encodingType = EncodingType.guessEncodingType( reader.getEncoding() );
代码示例来源:origin: pentaho/pentaho-kettle
EncodingType encodingType = EncodingType.guessEncodingType( reader.getEncoding() );
代码示例来源:origin: pentaho/pentaho-kettle
String encoding = data.isr.getEncoding();
data.encodingType = EncodingType.guessEncodingType( encoding );
代码示例来源:origin: pentaho/pentaho-kettle
EncodingType encodingType = EncodingType.guessEncodingType( reader.getEncoding() );
内容来源于网络,如有侵权,请联系作者删除!