Wouter Oet wrote:Well scrap that. I'm not sure any more. But you do try to close dis twice. On line 93 and 98.
Wouter Oet wrote:Couple of remarks:
Method names should start with a lowercase letter.
Sometimes you're logging with java.util.Logger (which isn't really a good solution, check out SLF4J) and other times you're using System.out.
Your constructors invoke overridable methods.
Your constructors execute functionality. I think it's better to use constructors only for initialization.
You could close resources sooner.
In Client on line 37 you probably want t.start() instead of t.run().
James Sabre wrote:In your client
In your server
Note - once you have wrapped a stream use only the wrapper or you could end up loosing data buffered in the wrapper.
James Sabre wrote:As I said earlier! Use a DataOutputStream and method writeUTF() to write the file name and then DataInputStream and method readUTF() to read it.
James Sabre wrote:Looks like I wasted my time; you are still using a buffered reader in the server!
From the java docs
public String readLine() throws IOException
Reads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.
Returns:
A String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached
James Sabre wrote:I haven't gone through the code in detail but these is at least one problem that could cause you to loose bytes. You get the file name from the input by wrapping the input in a BufferedReader and reading a line. You then use this name to create the file and then read the file content from a a BufferedInputStream which wraps the the original InputStream. This means that anything buffered in the BufferedReader will be lost forever.
Consider the use of DataInputStream and DataOutputStream. You can then use the readUTF() and writeUTF() methods to pass the file name and use the data streams directly to write and read the file content.
Edit: This code
is very suspect. You seem to be trying to read a buffer full of data and then write "something" but you sure as heck are not writing out the data you have written. All you need is something along the lines of
Note : there are very few legitimate uses for available() and in conjunction with reading from a socket like you are doing is definitely not one of them.
java.net.SocketException: Connection reset
Wouter Oet wrote:If you're able to write a multithreaded video encoding then you should be able to read documentation and use google.
I would advise you to read this and then you'll be able to comprehend why the
code you found is bad.
James Sabre wrote:
agustinus lumbantoruan wrote:
Im sorry, I think you misunderstand.
I understand perfectly.
This is not my homework. This is part of my Thesis.
Aha; it is all clear now; it is not homework! Am I missing something? What is the essential difference between 'homework' and 'thesis' when it comes to who is supposed to do the work?
My thesis is about Distributed Video encoding. I have done the RPC, file download, multi threading video encoding. The last part is uploading the video back to the server.
Im seeking for a help.
So have you followed the same approach for the rest of your thesis? Did you take a copy of someone else's work and get a forum to massage that so that it met your brief? It would seem to me that anyone who can do significant work on "Distributed Video encoding" should find the modification required to the upload code to be trivial. You are not so much "seeking for a help" as requesting someone to do the work for you.
Am I being unjust?
James Sabre wrote:Interesting. You say "I understand most of the code" yet you want somebody to modify in an almost trivial manner some poor quality and flawed code that you found on the Internet.
This sounds very very like a request to do your homework.