wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes sending string using writeUTF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "sending string using writeUTF" Watch "sending string using writeUTF" New topic
Author

sending string using writeUTF

Anjali Malar
Greenhorn

Joined: Apr 09, 2011
Posts: 6


Hi all,
I have been using Java Ranch for a long time. But this is my first post. Happy to interact with you all.

I am writing a client server program as a part of project. In that the client need to send parts of file (size varies from 256 bytes to 64KB ) to server.
So I used DataOutputStream and writeUTF(String s) method to send the file parts.
But the problem is server is able to get the first part and for second part it is not receiving.
I like to know is there any size constraints in string size we are sending in writeUTF() method? Can it send 64KB data to server ?

Thanks

Jared Malcolm
Ranch Hand

Joined: May 02, 2011
Posts: 54

I see nothing in the documentation that points towards a limitation....

readUTF();

writeUTF();

possibly provide some code to point towards an answer?


SCJA 6 (Studying for SCJP 6)
Yunnan Zhou
Ranch Hand

Joined: May 04, 2011
Posts: 31

readUTF and writeUTF are obstruction methods.
try readUTF in you server.
just like you wirte a message,the server must read it.or it will be obstructed
I hope this will help you.


I'am a Chinese.I like Java.Hello.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Welcome to the Ranch!

Can you show us some of your source code, especially the side that is receiving the string?

I suspect you might have an error like the issue described here: Read Doesn't Do What You Think It Does.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37970
    
  22
What's an obstruction method?
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

I think he means a blocking method.


luck, db
There are no new questions, but there may be new answers.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Jared Malcolm wrote:I see nothing in the documentation that points towards a limitation....

.... except this?
First, the total number of bytes needed to represent all the characters of s is calculated. If this number is larger than 65535, then a UTFDataFormatException is thrown.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37970
    
  22
Darryl Burke wrote:I think he means a blocking method.
Thank you
Jared Malcolm
Ranch Hand

Joined: May 02, 2011
Posts: 54

Darryl Burke wrote:
Jared Malcolm wrote:I see nothing in the documentation that points towards a limitation....

.... except this?
First, the total number of bytes needed to represent all the characters of s is calculated. If this number is larger than 65535, then a UTFDataFormatException is thrown.


Good call, I guess I didn't include this due to his max size fitting within this (figured there was probably some other issue) according to his original post. Since his max file size is at the threshold of how large he can transmit I'd probably recommend breaking it into parts first...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sending string using writeUTF
 
Similar Threads
how to disable session time out
Reading image and convert it to Base64 format
need help on posting xml over http
Quickie question about DataInput and Output Streams
transferring files using sockets