🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #15059

Re: Problems w/ code to transfer file

#15059
From: Tom Davies
Date: Thu, 15 Jul 1999 00:00
27 lines
1675 bytes
Darrel Davis wrote:
> 
> I'm a Java newbie in the middle of developing server-side code
> that transfers files to/from clients.  The clients send files and this
> method gets called.  Notice that I know the size of the file from
> the input parameters.
> 
> With this code, I seem to get the file but it is corrupted and not
> the correct number of bytes (always on the too big side).  These
> are sound files which makes it quite noticeable.  I'm sure the problem
> is simple for this group and any help is appreciated.

Accorting to the manual, DataOutputStream "lets an application write
primitive Java data types to an output stream in a portable way. An
application can then use a data input stream to read the data back in."

In other words, DataOutputString *doesn't* guarantee to write your data
as just the plain sequence of bytes you gave it.

[snip]
>       f_out = new DataOutputStream(new BufferedOutputStream (new
> FileOutputStream(sFileName)));

Try this without the DataOutputStream. And you probably shouldn't be
using DataInputStream either.

Tom
Technical Details
Message-ID: <378CF6F7.E2EF90B0@smartchat.net.au>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7mg96v$1863@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,227e1d885d7026d9
X-Google-Attributes: gidf74b3,public
From: Tom Davies <tom@smartchat.net.au>
Subject: Re: Problems w/ code to transfer file
Date: 1999/07/15
Message-ID: <378CF6F7.E2EF90B0@smartchat.net.au>
X-Deja-AN: 500864445
Content-Transfer-Encoding: 7bit
References: <7mg96v$1863@forums.borland.com>
To: Darrel Davis <darreld@his.com>
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language