Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Nov 2003 14:26:57 +0200
From:      Alexey Zelkin <phantom@FreeBSD.org.ua>
To:        Milo Hyson <milo@cyberlifelabs.com>
Cc:        FreeBSD Java Mailing List <freebsd-java@freebsd.org>
Subject:   Re: Odd String behavior
Message-ID:  <20031105142657.A95628@phantom.cris.net>
In-Reply-To: <3FA82A39.5060500@cyberlifelabs.com>; from milo@cyberlifelabs.com on Tue, Nov 04, 2003 at 02:37:45PM -0800
References:  <3FA82A39.5060500@cyberlifelabs.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Please send me privatelly complete test case and html file which
you using.  I'll look for the problem.

PS: BTW, can you please try same code using linux-sun-* JVMs and see
if it differs too.

On Tue, Nov 04, 2003 at 02:37:45PM -0800, Milo Hyson wrote:
> For some reason, the following code fragment performs differently on two 
> different machines:
> 
> int  length  = (int)htmlFile.length();
> byte bytes[] = new byte[length];
> logger.info("length = " + length);
> 
> InputStream in = new FileInputStream(htmlFile);
> 
> for (int offset=0; length>0; )
> {
>     int numRead = in.read(bytes, offset, length);
>     logger.info("numRead = " + numRead);
> 
>     if (numRead == -1)
>         break;
> 
>     offset += numRead;
>     length -= numRead;
> }
> 
> in.close();
> 
> String rawHTML = new String(bytes, "UTF-8");
> logger.info("rawHTML = " + rawHTML.length() + " characters");
> 
> 
> On 4.9-RELEASE with native JDK 1.4.1-p3, I get the following correct output:
> 
> 30799 [main] INFO com.internetdentalalliance.doorway.builder.TemplateFactory  - length = 18936
> 30799 [main] INFO com.internetdentalalliance.doorway.builder.TemplateFactory  - numRead = 18936
> 30806 [main] INFO com.internetdentalalliance.doorway.builder.TemplateFactory  - rawHTML = 18936 characters
> 
> 
> However, on 4.5-RELEASE with native JDK 1.3.1-p7, I get the following 
> erroneous output:
> 
> 3046 [main] INFO com.internetdentalalliance.doorway.builder.TemplateFactory  - length = 18936
> 3046 [main] INFO com.internetdentalalliance.doorway.builder.TemplateFactory  - numRead = 18936
> 3052 [main] INFO com.internetdentalalliance.doorway.builder.TemplateFactory  - rawHTML = 11419 characters
> 
> 
> It's losing 40% of the characters when converting the raw bytes to a 
> String. Any ideas?
> 
> -- 
> Milo Hyson
> Chief "Mad" Scientist and Director of Asian Operations
> CyberLife Labs, LLC
> 
> 
> _______________________________________________
> freebsd-java@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-java
> To unsubscribe, send any mail to "freebsd-java-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031105142657.A95628>