473,396 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Client Server problems in java

I want to sent a .dat file from the server to the client and have the client put it in an array and display it. My problem is on the server end but i jus dont know what to do. can anyoner please help me, here's what i've got so far:

Scanner FileOut = new Scanner(new File("test.dat"));
byte[] dataOut = new byte[1024];
dataOut = FileOut.toString().getBytes();

DatagramPacket outPacket = new DatagramPacket (dataOut, dataOut.length, group, clientPort);

socket.send(outPacket);
System.out.println("File sent to client");


whats missing/ where m i going wrong.
it's UDP by the way
Apr 7 '09 #1
3 2191
JosAH
11,448 Expert 8TB
The Scanner.toString() method doesn't do what you might think it does: it just returns a String representation of the Scanner, not the content of the stream it's scanning. Read the API documentation for details.

kind regards,

Jos
Apr 7 '09 #2
would it be possible for you to send me some code that would work for what i am trying to do?
Apr 7 '09 #3
JosAH
11,448 Expert 8TB
@RockyIV
Read the API documentation for the InputStream class; a link to the documentation can be found in the very first article of this group "Read This First". You should read data from the InputStream and pass it to your destination through the UDP socket. There's no need for a Scanner here; scanners are for text, not binary data.

kind regards,

Jos
Apr 8 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Krist | last post by:
Hi All, Our customer has just decided to choose as development standard. The application is HR application with report. While many like Web client, Java application/thick client is still...
2
by: mb12036 | last post by:
All- Having a problem installing a DB2 client on a machine running AIX version 5.0. Client appeared to install one time succesfully, then was uninstalled and a reinstall was attempted. For...
4
by: Prince Kumar | last post by:
I joined a company recently and they have a java program which hangs (does nothing) after a while. This is no way consistent. It could succeed quite a few times and can fail a few other times....
0
by: netgeni59 | last post by:
Hello fellow C# friends, I am trying to write a C# TCP client that was formerly written in Java. The server must still remain in Java. I cannot get text data from the C# client to be received...
7
by: David Laub | last post by:
I've also posted this issue to a Sun/java formum, but since it appears to be an integration issue, this may be the better place to posr: I have written a dot net/c# Web Services doesn't fully...
8
by: DW | last post by:
Hi, Here is my question. I want to push security prices to the desktop from the server. Whenever there is a new price in the database, the server notifies the client. How can this be done in...
0
by: Divyakumar Jain,SAP Netweaver consultant | last post by:
Hi all, I have created an web service on SAP system. I have created a .net client using Micrsoft Visual Studio 2003 and .net frame work 2.0. in Visual Basic. In that .net client i have created...
1
by: fortepianissimo | last post by:
I have a simple xmlrpc server/client written in Python, and the client throws a list of lists to the server and gets back a list of lists. This runs without a problem. I then wrote a simple Java...
4
by: Jon Slaughter | last post by:
How do I go about accessing some client side control? I'm trying to design a web site in asp.net(well, I want to but I'm seeing that JSP might be better. I don't like java but I do like the fact...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.