That's a pleasure. Do show us the improved version.murali jackson wrote:Thanks All . . . It was very helpfull . . .
Campbell Ritchie wrote:That's a pleasure. Do show us the improved version.
Nonononononononono.murali jackson wrote:. . .. . .
Yesyesyesyesyesyes. Well done That will work. By using the strange syntax in line 20, you make sure you only read each line once, so you get the whole of the line. I notice you have also got advance→dvance and begin→egin, so it does appear that the read() method is consuming the first letter of each line. Line 20 (as I said) makes sure you don't read two lines per loop; you would miss alternate lines and there is a risk that the last line in the output would read “null”.
Carey Brown wrote:You can send a file name but if your server and client are on two different machines that won't work. Otherwise you have to send all the bytes of the file. When doing this the typical approach is to load the file into a byte[] that can hold the whole file, then send the length of the array in the first four bytes followed by the buffer contents.
Carey Brown wrote:
How are the client and server supposed to communicate with each other? Sockets? HTTP? File name if they're on the same machine?
murali jackson wrote:Could you please share some sample code or tell me what class and methods i need to use to load the file to byte[].
There are three kinds of actuaries: those who can count, and those who can't.
Norm Radder wrote:Will the file contain binary data? For example line end chararcters.
Norm Radder wrote: Can SOAP handle binary data? The byte array could be Base64 encoded to ensure no binary data.
Campbell Ritchie wrote:What would be wrong with reading the entire text into a single String, creating a byte[] of the appropriate size, and using String#getBytes()? Apart from the problem of changing line ends, as noted in the documentation comment of my FileCopier class?
Norm Radder wrote:Can you state what you are trying to do again? The last bits of code were for a small, specific part of the project. Can you post a higher level description of what you are trying to do?
the client will request a file from the server
server will send the requested file
client will process
and save the file
in the form of byte[]
Norm Radder wrote:Do you have a protocol for the requests the client sends to the server and for how the server responds to the client?
Carey Brown wrote:How are the client and server supposed to communicate with each other? Sockets? HTTP? File name if they're on the same machine?
murali jackson wrote:I am thinking of using this method as a Webservice operation. So i thing the protocol would be SOAP. Whenever a client makes a request to this service method.
It will send the byte[] as response and Client will process the byte[] to get the file. Thanks !!!
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|