Results 1 to 6 of 6

Thread: Encoding and FileInputStream

  1. #1
    Join Date
    Dec 2009
    Posts
    263

    Encoding and FileInputStream

    Hello,
    I have to read a file containing accented characters. They were generated with an editor requires manage encoding utf-8.
    I use the following classes:
    FileInputStream
    BufferedReader
    InputStreamReader
    I can easily (without specifying the encoding readers) recover accented characters in a String. I also use BufferedReader.readLine () without specifying the encoding. Now that this has been converted to utf-16, how to encode the inputstream which is in the buffer. Thank you for your replies.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: Encoding and FileInputStream

    Hello,
    For such rare cases where I needed to use a multitude of encoding, I used java.nio.charset .* package which is provided by java. Now, your problem seems "relatively" simple, I think it is unnecessary to go through this package.
    I would not recommend you this. If you want any more details of the java.nio.* package then feel free to ask, so that I can explain you.

  3. #3
    Join Date
    Dec 2009
    Posts
    263

    Re: Encoding and FileInputStream

    Hello,
    Actually my problem is any beast and there must be a way to handle this more "simply". Maybe at the stream of bytes in Manager, but the code is beyond my scope. Your solution seems simple. My problem is that does not even know what encoding is used in my case . I just know it's code like this in the database that I use. I guess it's 8-bit seen that accented characters in the utf16 version gives 2 characters in the desired encoding. An idea? A basic question, To try to understand if one uses InputStreamReader (FileInputStream), without specifying the encoding, then, the stream 'transcode' format system default to utf-16 encoding which is used by Java. Is this correct?

  4. #4
    Join Date
    Nov 2005
    Posts
    3,026

    Re: Encoding and FileInputStream

    Hello,
    A basic question, To try to understand if one uses InputStreamReader (FileInputStream), without specifying the encoding, then, the stream 'transcode' format system default to utf-16 encoding which is used by Java. Is this correct?
    Yes, absolutely!
    When you use a String there was an encoding UTF-16 And the InputStreamReader handles this encoding. But then he must repeat the opposite when you want to save your StringUsing a OutputStreamWriter.

  5. #5
    Join Date
    Dec 2009
    Posts
    263

    Re: Encoding and FileInputStream

    Hello,
    What I want so I think it's utf-8 representation of string my (not so strange that AC encoding ). Is that using a CharsetEncoder to the utf-8 can walk? If this is the way forward, I welcome your offer of assistance stp. If I could get more information on this it would be great, and even I can learn something more.

  6. #6
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Encoding and FileInputStream

    Hello,
    Just have a look at the following part of the code, it is not the whole code, just a part of it, but you can definitely be benefited by it.
    Here is the code
    Code:
    Charset chst = Charset.forename("UTF-8");
    CharsetEncoder encd = chst.newCharsetEncoder();
    ByteBuffer bb = encode.encodes(monCharBuffer)
    / / At this time, your bb contains chst UTF8 encoded, it does you just have to send it wherever you want.

Similar Threads

  1. Replies: 3
    Last Post: 15-03-2011, 06:19 PM
  2. H.264 Encoding using StaxRip
    By Luis-Fernando in forum Windows Software
    Replies: 6
    Last Post: 05-05-2010, 10:34 PM
  3. GTX 295 accelerated encoding with Premiere Pro CS4
    By Aaron007 in forum Monitor & Video Cards
    Replies: 5
    Last Post: 21-04-2010, 03:52 PM
  4. FileInputStream and StringTokenizer
    By Logan 2 in forum Software Development
    Replies: 5
    Last Post: 28-01-2010, 12:55 PM
  5. FileInputStream Problem with UTF-8
    By Remedy in forum Software Development
    Replies: 5
    Last Post: 20-01-2010, 11:19 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,884,193.61271 seconds with 16 queries