KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > nio > charset > CharsetDecoder

java.nio.charset
Class CharsetDecoder

java.lang.Object
  extended by java.nio.charset.CharsetDecoder
See Also:
Top Examples, Source Code, decodeLoop, onUnmappableCharacter, onMalformedInput, replaceWith, replace, report, ignore, CoderResult, flush, decode, reset, ByteBuffer, CharBuffer, Charset, CharsetEncoder

public final float averageCharsPerByte()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1071]Reference CharsetDecoder examples at IBM
By Thomas SMETS on 2004/10/27 07:41:49  Rate
There is also a set of simple example from Johm ZUKOWSKi @ IBM 
 http://www-106.ibm.com/developerworks/java/library/j-mer03253.html?c


public final Charset charset()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[524]Charset decoding
By Anonymous on 2004/10/20 07:45:52  Rate
import java.nio.*; 
 import java.nio.channels.*; 
 import java.nio.charset.*; 
  
  
 CharSet cs = CharSet.forName ( "ISO-8859-1" ) ; 
 CharsetDecoder decoder = cs.newDecoder (  ) ; 
  
  
 FileInputStream fis = new FileInputStream ( new File ( fileName )  ) ; 
 FileChannel fc = fis.getChannel (  ) ; 
 int fs =  ( int ) fc.size (  ) ; 
 MappedByteBuffer mbb = fc.map ( FileChannel.MAP_RO, 0, fs ) ; 
 CharBuffer cb = decoder.decode ( bb ) ; 
  
  
 // Do some processing 
 fc.close (  ) ;


[1059]_
By Thomas SMETS on 2004/10/20 07:45:16  Rate
package demo; 
  
  
 import java.io.File; 
 import java.io.FileInputStream; 
 import java.io.IOException; 
 import java.nio.CharBuffer; 
 import java.nio.MappedByteBuffer; 
 import java.nio.channels.FileChannel; 
 import java.nio.charset.Charset; 
 import java.nio.charset.CharsetDecoder; 
  
  
 public class CharsetDecoderExample  {  
   // Provide an file name located in the classpath 
   public static final String fileName = "datasource.properties"; 
    
   public static void main ( String [  ]  args )   
     throws IOException 
      
    {  
     Charset cs = Charset.forName ( "ISO-8859-1" ) ;  
     CharsetDecoder decoder = cs.newDecoder (  ) ;  
  
  
     FileInputStream fis  
       = new FileInputStream  ( new File  (  CharsetDecoderExample.class.getClassLoader (  ) .getResource ( fileName ) .getFile (  ) .toString (  )  )  ) ; 
   
     FileChannel fc = fis.getChannel (  ) ;  
     int fs =  ( int ) fc.size (  ) ;  
     MappedByteBuffer mbb = fc.map ( FileChannel.MapMode.READ_ONLY, 0, fs ) ;  
     CharBuffer cb = decoder.decode ( mbb ) ; 
      
     System.out.println ( "Buffer content is \n : " + cb ) ; 
      
      
 // Do some processing  
     fc.close (  ) ; 
  
  
    }  
  } 


protected CharsetDecoder(Charset cs,
                         float averageCharsPerByte,
                         float maxCharsPerByte)
See Also:
IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final CharBuffer decode(ByteBuffer in)
                        throws CharacterCodingException
See Also:
CodingErrorAction.REPORT, UnmappableCharacterException, MalformedInputException, IllegalStateException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final CoderResult decode(ByteBuffer in,
                                CharBuffer out,
                                boolean endOfInput)
See Also:
CoderMalfunctionError, reset, IllegalStateException, decodeLoop, CodingErrorAction.REPORT, unmappable action, unmappable-character, malformed action, malformed-input, CoderResult.OVERFLOW, CoderResult.UNDERFLOW, out.remaining()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract CoderResult decodeLoop(ByteBuffer in,
                                          CharBuffer out)
See Also:
CoderResult.UNDERFLOW, decode, out.remaining()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Charset detectedCharset()
See Also:
UnsupportedOperationException, IllegalStateException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final CoderResult flush(CharBuffer out)
See Also:
decode, reset, IllegalStateException, CoderResult.OVERFLOW, CoderResult.UNDERFLOW, implFlush, out.remaining()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected CoderResult implFlush(CharBuffer out)
See Also:
CoderResult.OVERFLOW, CoderResult.UNDERFLOW
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected void implOnMalformedInput(CodingErrorAction newAction)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected void implOnUnmappableCharacter(CodingErrorAction newAction)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected void implReplaceWith(String newReplacement)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected void implReset()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isAutoDetecting()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isCharsetDetected()
See Also:
UnsupportedOperationException, detectedCharset
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public CodingErrorAction malformedInputAction()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final float maxCharsPerByte()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final CharsetDecoder onMalformedInput(CodingErrorAction newAction)
See Also:
IllegalArgumentException, implOnMalformedInput
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final CharsetDecoder onUnmappableCharacter(CodingErrorAction newAction)
See Also:
IllegalArgumentException, implOnUnmappableCharacter
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final String replacement()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final CharsetDecoder replaceWith(String newReplacement)
See Also:
IllegalArgumentException, implReplaceWith
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final CharsetDecoder reset()
See Also:
implReset
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public CodingErrorAction unmappableCharacterAction()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags