From owner-freebsd-java@FreeBSD.ORG Wed Nov 5 04:18:21 2003 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 82BB716A4CE for ; Wed, 5 Nov 2003 04:18:21 -0800 (PST) Received: from phantom.cris.net (phantom.cris.net [212.110.130.74]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7940643FE0 for ; Wed, 5 Nov 2003 04:18:18 -0800 (PST) (envelope-from ml@FreeBSD.org.ua) Received: (from ml@localhost) by phantom.cris.net (8.12.6/8.12.6) id hA5CQvXQ095647; Wed, 5 Nov 2003 14:26:57 +0200 (EET) (envelope-from ml) Date: Wed, 5 Nov 2003 14:26:57 +0200 From: Alexey Zelkin To: Milo Hyson Message-ID: <20031105142657.A95628@phantom.cris.net> References: <3FA82A39.5060500@cyberlifelabs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3FA82A39.5060500@cyberlifelabs.com>; from milo@cyberlifelabs.com on Tue, Nov 04, 2003 at 02:37:45PM -0800 X-Operating-System: FreeBSD 4.7-STABLE i386 cc: FreeBSD Java Mailing List Subject: Re: Odd String behavior X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Nov 2003 12:18:21 -0000 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"