Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-06-2007, 08:38 PM
Senior Member
 
Join Date: Nov 2007
Posts: 115
Rep Power: 0
ravian is on a distinguished road
Default Socket programming - accepting files
I have written a Socket Server that is listening at some port. I am getting input from my client using DataInputStream. Review the code below:

Code:
DataInputStream input;
try {
input = new DataInputStream(MyClient.getInputStream());
}
catch (IOException e) {
       System.out.println(e);
}
I want the user to send me File objects as well. Is this possible which the code above or I have to make some changes?

Thanks for your time.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-29-2007, 11:38 AM
Member
 
Join Date: Nov 2007
Posts: 12
Rep Power: 0
javagk is on a distinguished road
Default
Yes, you may send files using Socket client. use FileOutputStream in that case.

Code:
BufferedOutputStream bos = new BufferedOutputStream
                        (new FileOutputStream("fileName.txt"));
Make sure to catch exceptions.

Happy coding.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-29-2007, 11:40 AM
Senior Member
 
Join Date: Nov 2007
Posts: 115
Rep Power: 0
ravian is on a distinguished road
Default
Thanks. I will try that.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Socket Programming (Client) JavaForums Java Blogs 0 11-26-2007 05:00 PM
Socket Programming (Server) JavaForums Java Blogs 0 11-26-2007 05:00 PM
Socket programming - port issues ravian Networking 2 11-07-2007 11:24 AM
Programming Socket Question paul Networking 1 07-30-2007 08:26 PM
send files through socket bbq Advanced Java 1 06-05-2007 03:08 AM


All times are GMT +2. The time now is 11:06 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org