Transfering files via sockets

Hi
I am writing a client server app, and am communicating between the clients and server using the Socket and Serversocket class's. Transfering strings is very easy, but i also want to transfer files. I usually use Fileinputstream/fileoutputstream in normal circumstances, but i dont think this will work with sockets.
Any suggestions on how i can transfer files through a sockets would be most welcome.
Cheers
Steve

Just create the InputStream to your file, read in some bytes, write the bytes to the sockets OutputStream, voila!
Rob.

Similar Messages

  • HT4889 Transferred files via time machine and not log in password will not allow me to log in

    I have a new MacBook pro, I transferred files via time machine and a removable hard drive. Now new MacBook does not recognize the log in password. What can I do to reset the password?

    Did you migrate when you first booted up in Setup Assistant or did you migrate later? When you migrate later it can create a second account, check in Mac HD/Users to see if this is the situation.

  • How the external system will talk to ECXpert 3.5 for transfering files via HTTP SSl?

    We are using ECxpert3.5 on Solaris box. One of our Trading Partner want to communicate through HTTP-SSL and we are doing XML/EDI mapping. Could you guide us what steps we need to take care to implement this.
    How the external system will talk to ECXpert for transferring files. (We need the syntax for the URL). How ECXpert will receive XML file through HTTP-SSL protocol from External System and file submittion.
    Please send is there any other document which explain about. Thanks in advance for your help. [email protected] or [email protected]

    Hi Steve,
    You can bring the GRC framework to a state equivalent to a raw install by following options:
    Option 1.) You should have a base-line backup before GRC installation. If so then apply that base-lin backup and deploy GRC components. If there is no base-lin backup, then
    Option 2.) Uninstall and re-install J2EE and then follow up with rest of the installation process. If you don't want to go through re-install process, then
    **Correction to Option 3**
    Option3.) SAP is in process of creating a SAP Note for Delete script, Instead of delivering Delete Script script via OSS message.  Will update you as soon as the Note gets released.
    Please refere to Note # 1416728 to Manage your deletion in RAR 5.3 SP10.
    Hope this helps.
    Best Regards,
    Sirish Gullapalli.

  • Transferring files via Target Mode

    Hello,
    I just got my Mac Pro and I'm trying to transfer some files and programs from my existing G4... I have heard about using the "Target Mode" to do this, but when I tried no luck. Here's what I attempted to do:
    attmept #1. G4 is connected to my display. I booted the G4 holding down the "T" key. I see the firewire symbol on the screen, so I connected a firewire cable from the G4 to the Pro and turned on the Pro. Nothing happened. Should I have connected the display cable to the Pro too? I don't need 2 displays to do this action, right?
    attempt #2. Mac Pro is connected to the display. I boot the Pro and follow instructions via "Migration Assistant". So I connected the firewire from the Pro to the G4 (while Pro is still running) and booted the G4 while holding down the "T" key and still nothing happens.
    What am I doing wrong? Can anyone offer some assistance please? Thanks in advance.

    Hi hscarr;
    Transferring programs from a G4, which is PowerPC architecture, to a Mac Pro, which is Intel architecture, is a know method of creating problems.
    It is highly recommend that instead all applications be freshly install on the Intel platform.
    Once that is done that your data can be moved.
    Allan

  • Read the content of a file (via socket)

    Hi,
    I need to read the content of a file (.txt, or better, .jpg) and to write it again in another file.
    I have this code (in Javascript):
        conn = new Socket;
        conn.encoding = "BINARY";
        if (conn.open ("127.0.0.1:8888")) {
        conn.timeout=30;
        conn.writeln("GET variousFiles/file.jpg HTTP/1.1");
        reply = conn.read(999999);
        conn.close();
        var file = new File("C:/APPS/New_File.txt");
        file.encoding = 'BINARY';
        var open_file = file.open("w+");
        file.write(reply);
        } else { alert("Errore: " + conn2.error); }
    However my new file is always empty, because I can not read the content of the first file.
    My variable "reply" is always empty.
    Thanks and best regards.

    There is a particular case with sugested function, if content is generated on the fly by the server -php, cgi, etc.-
    In this case, http server doesn´t knows total size of response data, so response shows a chunked transfer-encoding header and data is parted in chunks, each one starting with it´s size, and following the data.
    HTTP/1.1 200 OK
    Date: Tue, 30 Apr 2013 12:43:41 GMT
    Server: Apache/1.3.31 (Win32) mod_fastcgi/2.4.1
    Connection: close
    Transfer-Encoding: chunked
    Content-Type: image/jpeg
    f49
    ÿØÿà  JFIF
    I´m using this function to decode parted response, with initial chunkedString with firs chunk size; in this case, f49:
    PartsSeparator="\r\n";
    function getPartedBody(partedBodyString) {
        var separatorPosition=partedBodyString.indexOf(PartsSeparator);
        var chunkSize=new Number("0x"+partedBodyString.substring(0,separatorPosition));
        separatorPosition+=PartsSeparator.length;
        var bodyString=new String("BINARY");
        bodyString="";
        if (chunkSize>0)
            bodyString=partedBodyString.substring(separatorPosition,separatorPosition+chunkSize)+
                getChunkedResponse(partedBodyString.substring(separatorPosition+chunkSize+PartsSeparator. length));
        return bodyString;
    Hope this helps
    regards

  • Transfering Files using Sockets

    Hello, im new to Java network. Im trying to build a client-server application that reads a file, converts it to bytes and writes it to socket. A server application then gets the bytes, and writes the file to the remote location.
    It seems whatever i do results to errors.
    Any ideas what might be the fault?
    Regards
    Client
    ========
    import java.io.DataOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.net.Socket;
    import java.net.UnknownHostException;
    public class DataHandler {
         static Socket toServer;
         static byte[] bytes;
         static DataOutputStream out;
         public DataHandler(byte[] bytesReturned) {
              bytes = bytesReturned;
         public static void performActions(File fileGiven) throws IOException {
              try {
                   System.out.println("class CH");
                   toServer = new Socket("localhost", 18583);
                   readInput(fileGiven);
                   sendData();
              catch (UnknownHostException ex) {
                   System.err.println(ex);
              catch (IOException ex) {
                   System.err.println(ex);
              finally{
                   closeConnection();
         private static void closeConnection() throws IOException {
              out.close();
              toServer.close();
         public static byte[] readInput(File file) throws IOException {
              InputStream is = new FileInputStream(file);
              // Get the size of the file
              long length = file.length();
              if (length > Integer.MAX_VALUE) {
                   // File is too large
              // Create the byte array to hold the data
              bytes = new byte[(int) length];
              // Read in the bytes
              int offset = 0;
              int numRead = 0;
              while (offset < bytes.length
                        && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) {
                   offset += numRead;
              // Ensure all the bytes have been read in
              if (offset < bytes.length) {
                   throw new IOException("Could not completely read file "
                             + file.getName());
              // Close the input stream and return bytes
              is.close();
              System.out.println(bytes);
              return bytes;
         private static void sendData() throws IOException {
              out = new DataOutputStream(toServer.getOutputStream());
              out.write(bytes);
         public static void main (String args[]){
              File file = new File("test.pdf");
              try {
                   performActions(file);
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    Server
    =======
    import java.io.DataInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.net.ServerSocket;
    import java.net.Socket;
    public class Receiver {
         static ServerSocket server;
         static Socket connection;
         static DataInputStream input;
         public static void runServer() throws Exception{
              try {
                   server = new ServerSocket(18583);
                   while (true){
                        getStreams();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              finally{
                   server.close();
                   connection.close();
         private static void getStreams() throws Exception {
              connection = server.accept();
              input = new DataInputStream(connection.getInputStream());
              System.out.println(input);
              byte[] store = new byte[input.readByte()];
              input.read(store);*/
              FileOutputStream fos = new FileOutputStream("received.pdf");
              fos.write(input);
              fos.close();
         public static void main (String args[]){
              try {
                   runServer();
              } catch (Exception e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    }

    Ah, thanks a lot for the replies.
    It appears that i had some kind of writing to file error in server code at: fos.write(input);
    Its been fixed now.
    Non the less thank you very much for bothering :-)
    A silly question though. How is it possible to retain filename and filetype when sending a file? i.e. instead of having a FileOutputStream writing to a predefined by a string File (i.e. File file = new File("a_picture.jpg");) being able to send any type of file and keep their current format and name?
    I assume you should first send a string with the file name but the BufferedInputStream i have at the server mixes up both String and actual file bytes.
    Excuse me for the long question
    Kind Regards
    Chris

  • Transferring files via iPod

    Can I transfer photos/music from computer to computer via my ipod?
      Windows XP  

    You can use your iPod as a portable hard drive and transfer photo's, music or any other sort of file. See here for a "how to" http://www.apple.com/support/ipod/tutorial/ipgettingstartedt13.html

  • Transferring files via POST

    i wrote a servlet that reads a POSTed form that transferred a file. i am
              unable to interpet the file, any ideas ?
              Hashtable
              h=HttpUtils.parsePostData(request.getContentLength(),request.getInputStream(
              for (Enumeration en = h.elements(); en.hasMoreElements() ;) {
              out.println("" + en.nextElement());
              i get errors or garbage
              

    thanks anyway, succeeded. If anybody wants to know how, email me.
              "Lior Shapira" <[email protected]> wrote in message
              news:8cpimi$hn2$[email protected]..
              > i wrote a servlet that reads a POSTed form that transferred a file. i am
              > unable to interpet the file, any ideas ?
              >
              > Hashtable
              >
              h=HttpUtils.parsePostData(request.getContentLength(),request.getInputStream(
              > ));
              > for (Enumeration en = h.elements(); en.hasMoreElements() ;) {
              > out.println("" + en.nextElement());
              > }
              >
              > i get errors or garbage
              >
              >
              

  • Transfering files through sockets

    Hi
    I am still having difficulties making this work.
    I want to transfer a file (.exe, .zip) etc through a socket.
    I have created a fileinputstream to the file, and read in all its bytes.
    I then create an outputstream with the sockets output stream(socket is called incomming):
    FileInputStream fin = new FileInputStream("D:\\steve.txt");
    int size = fin.available();//for they byte array!
    System.out.println("Number of bytes in this file is " + size);
    byte b[] = new byte[size];//byte buffer holds the exact number of bytes the file contains!
    fin.read(b);
    OutputStream fileSender = incomming.getOutputStream();
                   fileSender.write(b, 0, size);
                   fileSender.close();
    I am positive the byte array holds all the bytes in the file as i have tested that.
    The problem is i dont seem to get anything out the client end. I pass along the file size and construct a byte array to hold it this is the client code:
    InputStream inFile = soc.getInputStream();
    populateTextArea("reading bytes!");
    byte b[] = new byte[inLineNum]; //inLIneNum is the correct size for sure
    inFile.read(b,0, inLineNum);
    FileOutputStream foutnew = new FileOutputStream("C:\\TEMP01\\STevenTESTtest.txt");
    foutnew.write(b);
    The resulting file contains nothing, all it contains is a load of ascii code (00).
    Any suggestions please, I'm probably missing something really dumb but I've spent about 5 hours and am totally fed up with it.
    Steve

    hehe it was working all the time, its just that my test files are large (typically over 5 meg) so its taking ages to transfer....So, does anyone know how to speed up a socket connection (if its even possible).
    Cheers
    Steve

  • Transferring Files via File Sharing from 10.4.11 to 10.8.5

    I am trying to get all of my files and information off of my laptop and migrate them to my new iMac. I have followed the instructions in regards for file sharing. However, when I bring up the finder and click on shared, the only thing that it will do is log me in as a guest. When I try and type in the password to log me in as a registered user it tells me that the password is wrong. Unless there is another password that I am unaware of I am 100% sure that I remember the password. Any help would be greatly appreciated.

    mwheelsnyc wrote:
    I am trying to get all of my files and information off of my laptop and migrate them to my new iMac. I have followed the instructions in regards for file sharing. However, when I bring up the finder and click on shared, the only thing that it will do is log me in as a guest. When I try and type in the password to log me in as a registered user it tells me that the password is wrong. Unless there is another password that I am unaware of I am 100% sure that I remember the password. Any help would be greatly appreciated.
    Check out the following:
    Setting-up a new Mac from an old one, its Backups, or a PC 
    Using  Setup  Assistant  on  Mountain  Lion  or  Lion

  • Pixel flicker to right of screen when transferring files via USB

    Hi there, just discovered this evening this strange flickery pixel effect that occurs for some reason, only started happening today, and I was wondering if I should get it checked out if it progresses into something worse. It's only happening when transferring items from a FAT 32 external harddrive, and occurs once every time I move one item to the desktop for half a second. Here's a youtube vid of it;
    http://www.youtube.com/watch?v=j5ZFhACzXaM&feature=player_profilepage

    Hi hscarr;
    Transferring programs from a G4, which is PowerPC architecture, to a Mac Pro, which is Intel architecture, is a know method of creating problems.
    It is highly recommend that instead all applications be freshly install on the Intel platform.
    Once that is done that your data can be moved.
    Allan

  • Transfering files via screen share

    I am able to screen share with my powerbook and my iMac. I tried to drag a folder with photo files on it from my iMac to the powerbook, but it didn't work. Any suggestions? Maybe easier to connect firewire, but wanted to try with screen share.
    Thanks

    you can't do this with screen share, sorry. You can do it using file sharing if your computers are on the same network.

  • Oracle BAM to monitor transfer of files using sockets

    Hi,
    We have two programs transferring files using sockets. We wanted BAM to monitor the transfer.
    Would you please suggest if this is achievable in BAM , and if so , any pointers to how we may go about implementing it .
    Cheers,
    Anant.

    You could generate success/failure/progress from your utility to JMS or call BAM webservices to populate BAM Data Objects. Reports could be built on top of that.

  • 6300's problem of transfer file via bluetooth

    Hi..i just got a brand new 6300
    but i've got a problem with transfering file via bluetooth from my laptop to my phone
    sumhow i can transfer file from my phone to my laptop, and i also can transfer image file from my laptop to my phone...
    but a problem occured when i try to send MP3s file from my laptop to my phone...
    i've already succeed to pair my laptop and my phone...but still i can't transfer thoose files...
    can anyone help me??
    please...
    thx a bunch

    Make sure that you have enough phone memory available, even if you are transferring to the memory card.
    When sending files by bluetooth they are transfered (cached) to the phone then the phone transfers them to the memory card.
    Also you should transfer files one at a time.
    If you are transfering lots of MP3's you would be better off using a data cable as it will be a lot quicker.

  • Transfer files via. WiFi?

    Transferring files via. bluetooth is a relatively long process (both Blackberry smartphones and the Windows XP bluetooth interface require you to click "Receive a File" before then going to the opposing device and clicking send a file for security purposes) with a slow transfer speed.
    Given both my computer and my smartphone are connected to the same secure WiFi network, is it possible to transfer files between the two? On my previous Nokia phone I could browse the Shared Files of my computer over the wireless network, and copy/paste to/from these files.
    I'm surprised it's not a more common feature on WiFi enabled smartphones. I'm sitting at my desk with my two devices side by side and already practically linked and I can't do anything about it. 
    Currently I'm emailing files to myself, then they instantly pop up on the BlackBerry. But this is unnecessarily using the actual internet connection, as opposed to the the device-to-device style connection you can use between computers when linked to the same network. 
    Any ideas? Ideal world I click "My Computer" - click "BlackBerry" and I browse from the root of my device with unlimited access. 

    Try Dukto, a small application for file sharing on howm wi-fi networks. You need to install both PC and phone utility. Application is available on the Ovi store.
    If a reply has solved your problem click Accept as solution button, doing it will help others know the solution. Thanks.

Maybe you are looking for

  • How to call a WD JAVA application from a WD ABAP application

    Hi experts, Here I have two applications with me. One has been created through WebDynpro ABAP while the other one has been created through WebDynpro JAVA. Now i have to call upon the JAVA aplication from my ABAp application. In other words in need to

  • Which Ram is better to go with?

    Hi, I was just wondering which Ram was better for my 2.2ghz intel core 2 duo 13 inch macbook which currently has 1 gb of ram. http://www.tigerdirect.ca/applications/searchtools/item-details.asp?EdpNo=435044 8&csid=ITD&body=MAIN OR http://eshop.macsal

  • Automatic sales order

    Hello, will SAP automatically create a sales order from a dependant or independant requirement one the planning time fence is reached.  So I know it will automatically create the PO from the PR in purchasing, does the same thing happen in the sales p

  • Full Screen in CS5 and CS5.1 is not Supporting the Menus Items like CS4 This is happening while

    Full Screen in CS5 and CS5.1 is not Supporting the Menus Items like CS4 This is happening while working in the balck screen and using shortkut Keys for top menu. the tools are woring, but while using Alt Key to choosing the menu item. its not support

  • Conundrum: videos require 1.0; camera connector 1.10?

    I have just recently discovered the Camera Connector, but understand that it requires software version 1.10, which is the yechy one that won't play your videos....???? Has anyone tried the Camera Connector with 1.0? Does it really require 1.10? Thank