Moving Files using sockets

I wanted to know of a good way to move, not copy, files using sockets? Any help would be great.
Thanks

Even on the same machine, you can only move a file on the same filesystem. i.e. the file appears in a different directory rather than copying the file.
If you have an C: and D: drive for example it will copy and delete the file on a move.
Unix allows you to have symbolic links which can make a file/directory from anywhere appear anywhere on your filesystem. It does not copy or actaully move the file, it just appears to be where ever you choose.

Similar Messages

  • Downloading a binary file using sockets without length known

    Hi all,
    I'm trying to download a binary(.exe) file using socket, where the length of the file is not known. Please take a look at the code I'm using:
          var readBin = socketBin.read();
         <-- Here comes the code that checks for http Content-length header field
         ; If content-length field is available, then I'll use it to download file, else proceed with following code -->
        pBar.reset("Downloading plugin..",null);pBar.hit(readBin.length);       
                while (1)
                    binFil.write(readBin);     //'binFil' is the file, into which downloaded file is written.
                    readBin = socketBin.read();
                    pBar.hit(readBin.length);
                    if( socketBin.eof || readBin.length<=0){
                        break;}          
                binFil.write(readBin);
                binFil.close();
                socketBin.close();
    Problem is: I'm able to download file within 10 seconds when content-length is known. But when content-length is not known, its taking about 1 and half minute to download, also the progress bar gets struck for much of time.
    FYI: socket is opened in binary mode, file is getting downloaded correctly(even though it takes abt a minute). BTW Im using CS5.5 extendscript
    I'm not able to figure out where the bug is.

    Hi, Srikanth:
    Sevaral points.
    #1 When posting code, please use the web interface and the >> icon and choose Syntax Highlighting >> Java. Otherwise your code is just too hard to read and gets misformatted.
    #2 Apropos of #1, your script as written does not work, because this line:
    url=url.replace(/([a-z]*):\/\/([-\._a-z0-9A-Z]*)(:[0-9]*)?\/?(.*)/,"$ 1/$2/$3/$4");
    has an extra space in the $1 and should be this:
    url=url.replace(/([a-z]*):\/\/([-\._a-z0-9A-Z]*)(:[0-9]*)?\/?(.*)/,"$1/$2/$3/$4");
    Please take an extra moment to make sure that when you asking for help, you do so in a way that makes sense. Otherwise it takes too much effort to help you, and that is frustrating.
    #3 If we instrument your script by adding a line to the while() loop:
                while (1)
                    binFil.write(readBin);
                    readBin = socketBin.read();
                    $.writeln(Date()+" Read "+readBin.length+" chars, eof is "+socketBin.eof);
                    if(  readBin.length<=0){         break;}              
    We get output like this:
    Mon Jul 11 2011 12:06:56 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:06:56 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:06:56 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:06:56 GMT-0400 Read 631 chars, eof is false
    Mon Jul 11 2011 12:07:06 GMT-0400 Read 0 chars, eof is false
    Result: undefined
    Therefore, we can reasonably conclude that the last read at the end of the data stream returns a short read when the other side blocks.
    Unfortunately, that's clearly insufficient since you can get short reads all the time.
    I'm not sure why you say the length of the file is not known, HTTP provides it to you in the Content-Length field of the response.
    But the easy answer is to get the server to close it for you. This is easy, enough, with Connection: close. Why were you specifying
    Connection: keep-alive, anyhow?:
                var requestBin =
                "GET /" + parsedURLBin.path + " HTTP/1.1\n" +
                "Host: " + parsedURLBin.address + "\n" +
                "User-Agent: InDesign ExtendScript\n" +
                "Accept: */*\n" +
                //"Connection: keep-alive\n\n";
                "Connection: close\n"+
                "\n";
    This yields a nice tidy:
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 735 chars, eof is true
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 0 chars, eof is true
    I suspect you're also better off using something like socketBin.read(64*1024) for a 64k buffer size, but it doesn't seem to effect the on-the-wire protocol, so perhaps its not so important.
    If you don't want to reply on the server

  • Send a picture file using sockets

    Hi,
    Could someone please tell me how I can send a picture file using sockets across a TCP/IP network? I have managed to do it by converting the file into a byte array and then sending it but I dont see the data back at the client when I recieve the file. I just see the byte array as having size 0 at client.
    Byte array size is correct at client side.
    //client code
    System.out.println("Authenticating client");
              localServer = InetAddress.getLocalHost();
              AuthConnection = new Socket(localServer,8189);
              out = new PrintWriter(AuthConnection.getOutputStream());
              InputStream is = AuthConnection.getInputStream();
              System.out.println(is.available());
              byte[] store = new byte[is.available()];
              is.read(store);
         ImageIcon image = new ImageIcon(store);
              JLabel background = new JLabel(image);
              background.setBounds(0, 0, image.getIconWidth(), image.getIconHeight());
              getLayeredPane().add(background, new Integer(Integer.MIN_VALUE));
    //extra code here
              catch (UnknownHostException e) {
    System.err.println("Don't know about host: LocalHost");
    System.exit(1);
              catch (IOException e) {
    System.err.println("Couldn't get I/O for "
    + "the connection to: LocalHost");
    System.exit(1);
    //server code
                   DataOutputStream out = new DataOutputStream(incoming.getOutputStream());
                   FileInputStream fin = new FileInputStream("3trees.gif");
                   byte[] b = new byte[fin.available()];
                   int ret = fin.read(b);
                   out.write(b);

    i used OutputStream as
    OutputStream out = incoming.getOutputStream(); and flushed the stream too.
    But I still get the same output on the client side. I tried sending a string and it works , but I cant seem to be able to populate the byte array on the client side. It keeps showing zero. Please advise.
    Thank you.

  • 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.

  • Sending file using sockets (difficult)

    Hi, i have the following section of code
    (of which i am not claiming ownership) which
    implements a DCC Send command from irc.
    It accomplishes this using sockets, and while
    i understand how the code accomplishes what it
    does, i need help with a possible modification.
    Basically what i am looking to do is keep track
    of the progress of the send - so that the
    user can at any time see how much of the file
    has been sent and how much is remaining.
    If anyone has done such a thing in the past or
    has a good idea as to how this should be implemented,
    i would be greatful for their help.
    Here is the code:
    new Thread() {
                public void run() {
                    try {
                        ServerSocket ss = new ServerSocket(0);
                        ss.setSoTimeout(timeout);
                        int port = ss.getLocalPort();
                        //byte[] ip = ss.getInetAddress().getAddress();
                        byte[] ip = InetAddress.getLocalHost().getAddress();
                        long ipNum = 0;
                        long multiplier = 1;
                        for (int i = 3; i >= 0; i--) {
                            int byteVal = (ip[i] + 256) % 256;
                            ipNum += byteVal*multiplier;
                            multiplier *= 256;
                        // Rename the filename so it has no whitespace in it when we send it.
                        // .... I really should do this a bit more nicely at some point ....
                        String safeFilename = file.getName().replace(' ', '_');
                        safeFilename = safeFilename.replace('\t', '_');
                        // Send the message to the user, telling them where to connect to in order to get the file.
                        sendCTCPCommand(nick, "DCC SEND " + safeFilename + " " + ipNum + " " + port + " " + file.length());
                        // The client may now connect to us and download the file.
                        Socket socket = ss.accept();
                        socket.setSoTimeout(30000);
                        // Might as well close the server socket now; it's finished with.
                        ss.close();
                        BufferedOutputStream output = new BufferedOutputStream(socket.getOutputStream());
                        BufferedInputStream input = new BufferedInputStream(socket.getInputStream());
                        BufferedInputStream finput = new BufferedInputStream(new FileInputStream(file));
                        byte[] outBuffer = new byte[bufferSize];
                        byte[] inBuffer = new byte[4];
                        int bytesRead = 0;
                        while ((bytesRead = finput.read(outBuffer, 0, outBuffer.length)) != -1) {
                            output.write(outBuffer, 0, bytesRead);
                            output.flush();
                            input.read(inBuffer, 0, inBuffer.length);
                        output.close();
                        input.close();
                        log("+++ DCC SEND Completed to " + nick + " (" + file.getPath() + ")");
                    }

    You already have the necessary code to find the number of bytes sent at any point during the transmission. You can find out the size of the file by instantiating a RandomAccessFile before you send it, and querying for the file length.
    I suggest you make the file size and bytes sent volatile and conveniently accessible to another thread (best implemented here as an inner class?). Your new thread will need to monitor the file transfer at intervals to update the progress indicator. You can generate estimates of time remaining by measuring the average transmission rate, and extrapolating using the total file size. Classically this is done using an average, but you might be better just maintaining a list of fairly recent samples, allowing for the speed swings inherent in internet connections.
    How you update the progress indicator from your monitor thread is up to you. I suggest exposing methods in the UI for setting the progress and time remaining, and simply update them from the monitor.
    Does this help any?

  • Reading / Writing files using Sockets

    Hi there guys,
    I am fairly new to this forum. I have been having a problem for the past three days. I am implementing a client/server implementation using Sockets which is a submodule of a project I am working on. What I want is that a files content are read and transferred over the network to the server that writes it down to a different file .
    What the code presently does is :
    <<<<Client Code >>>>
    It reads a file input.txt and sends the content over the network to the server.
    <<<< Server Code >>>
    It reads the incoming data from the client and writes the data out to a file called output.txt
    What I want now is that the server should read the file output.txt and send the contents to the client which reads it and then writes it down as a new file called serverouput.txt . After that I want to compare and see of the size of input.txt and serveroutput.txt . If both are same that means that data has been written reliably to the server.
    I have been trying to implement it for a long time and nothing seems to work out. I am posting the code for both client and server below. Any help in finalising things would be really appreciated.
    CLIENT CODE
    import java.awt.Color;
    import java.awt.BorderLayout;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.Date;
    import java.io.*;
    import java.net.*;
    class sc {
    static final int PORT = 4444;          //Change this to the relevant port
    static final String HOST = "127.0.0.1";
         //Change this to the relevant HOST,
    //(where Server.java is running)
    public static void main(String args[]) {
    try {
    System.out.print("Sending data...\n");
    Socket skt = new Socket(HOST, PORT);
                   // Set the socket option just in case server stalls
    skt.setSoTimeout ( 2000 );
                   skt.setSoKeepAlive(true);
    //Create a file input stream and a buffered input stream.
    FileInputStream fis = new FileInputStream("input.txt");
    BufferedInputStream in = new BufferedInputStream(fis);
    BufferedOutputStream out = new BufferedOutputStream( skt.getOutputStream() );
    //Read, and write the file to the socket
    int i;
    while ((i = in.read()) != -1) {
    out.write(i);
    //System.out.println(i);
                   // Enable SO_KEEPALIVE
    out.flush();
    out.close();
    in.close();
    skt.close();
    catch( Exception e ) {
    System.out.print("Error! It didn't work! " + e + "\n");
              catch( IOException e ) {
    System.out.print("Error! It didn't work! " + e + "\n");
    SERVER CODE
    import java.awt.Color;
    import java.awt.BorderLayout;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.Date;
    import java.io.*;
    import java.net.*;
    class ClientWorker implements Runnable {
    private Socket client;
    ClientWorker(Socket client) {
    this.client = client;
    public void run(){
    try      {
    FileOutputStream fos = new FileOutputStream("output.txt");
    BufferedOutputStream out = new BufferedOutputStream(fos);
    BufferedInputStream in = new BufferedInputStream( client.getInputStream() );
    //Read, and write the file to the socket
    int i;
    while ((i = in.read()) != -1) {
    out.write(i);
    //System.out.println(i);
    System.out.println("Receiving data...");
    out.flush();
    in.close();
    out.close();
    client.close();
    // srvr.close();
    System.out.println("Transfer complete.");
    catch(Exception e) {
    System.out.print("Error! It didn't work! " + e + "\n");
    class ss1 {
    ServerSocket server = null;
    ss1(){ //Begin Constructor
    } //End Constructor
    public void listenSocket(){
    try{
    server = new ServerSocket(4444);
    } catch (IOException e) {
    System.out.println("Could not listen on port 4444");
    System.exit(-1);
    while(true){
    ClientWorker w;
    try{
    w = new ClientWorker(server.accept());
    Thread t = new Thread(w);
    t.start();
    } catch (IOException e) {
    System.out.println("Accept failed: 4444");
    System.exit(-1);
    protected void finalize(){
    //Objects created in run method are finalized when
    //program terminates and thread exits
    try{
    server.close();
    } catch (IOException e) {
    System.out.println("Could not close socket");
    System.exit(-1);
    public static void main(String[] args){
    ss1 frame = new ss1();
         frame.listenSocket();
    }

    ............................................. After that I want to
    compare and see of the size of input.txt and
    serveroutput.txt . If both are same that means that
    data has been written reliably to the server.You don't need to do this. TCP/IP ensures the reliable transmition of data. By using a socket you are automaticaly sure that the data is reliably transmitted (Unless there is some sort of exception).
    To get the size of the files you can use a File object. Look it up in java.io package in API documentation.
    java-code-snippet (without error checking)
    File clientFile = new File("input.txt");
    clientFile.length();

  • How to Transfer files using socket remote method invocation?

    hello guys,
    i am working on java sockets...and i need to send and receive files though Java RMI. how will i go with it....
    Please do help me in this regard
    Edited by: sandeep_genevsoftech on Apr 4, 2008 4:32 AM

    I am also developing a similar application of file transfer but using sockets in place of RMI.The file gets transfered if i run client and server on same m/c(as localhost),but shows "access denied" if run on different m/c.I suppose some security policies need to be set.Can anybody help?

  • Trouble moving files using IMAP

    I'm using IMAP to access my email at work, but when I move a message from one folder to another, it is copying the messages instead of actually moving them. So for instance, my server has its own deleted items folder in order to fuly delete files from the server. When I am moving a file from my inbox to the deleted items folder, it only appears to be in the deleted items folder in Mail. But when I check it via webmail, the file shows up both in the deleted items folder, and still in my inbox. This is not an issue in Entourage. Any ideas?
    MacBook Pro 2GHz   Mac OS X (10.4.8)  

    There seems to be a lag with the Mail.app in regards to synchronization with messages stored on the server even when selecting "Automatically synchronize changed mailboxes" under the Advanced tab for the account preferences.
    As a test, after doing the same try taking the account offline and then online and or quit and re-launch the Mail.app.
    Check if the transferred message is still in both locations on the server.

  • Using FileIOInteractionSpec Class For Moving File using File Adapter

    Hi All,
    I am tring to use FileIOInteractionSpec class to move a file from one location to another. The problem is that I am not able to override its properties from BPEL, here is how the FileAdapter.jca file looks like which moves the file from one location to another:
    <adapter-config name="MoveFileService" adapter="File Adapter" wsdlLocation="MoveFileService.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
    <connection-factory location="eis/FileAdapter"/>
    <endpoint-interaction portType="MoveFile_ptt" operation="MoveFile">
    <interaction-spec className="oracle.tip.adapter.file.outbound.FileReadInteractionSpec">
    <property name="DeleteFile" value="true"/>
    <property name="PhysicalDirectory" value="C:\FileRead"/>
    <property name="FileName" value="dummy.txt"/>
    </interaction-spec>
    </endpoint-interaction>
    *<endpoint-interaction portType="MoveFile_ptt" operation="Move">*
    *<interaction-spec className="oracle.tip.adapter.file.outbound.FileIoInteractionSpec">*
    *<property name="Type" value="MOVE"/>*
    *<property name="SourcePhysicalDirectory" value="C:\FileRead"/>*
    *<property name="SourceFileName" value="dummy.txt"/>*
    *<property name="TargetPhysicalDirectory" value="C:\FileRead2"/>*
    *<property name="TargetFileName" value="dummyCopy.txt"/>*
    *</interaction-spec>*
    *</endpoint-interaction>*
    </adapter-config>
    In the above code, I have hard-coded the values, and it works fine like that.
    However, when I try to override these values by defining properies in BPEL invoke's tag, the values are getting passed as null.
    Here is the invoke tag code, tried the following 2 combinations:
    <invoke name="InvokeFileMove"
    inputVariable="InvokeFileMove_MoveFile_InputVariable"
    partnerLink="MoveFileService" portType="ns1:MoveFile_ptt"
    operation="Move" bpelx:invokeAsDetail="no">
    <bpelx:inputProperty name="jca.file.SourcePhysicalDirectory" value="C:\FileRead"/>
    <bpelx:inputProperty name="jca.file.SourceFileName" value="dummy.txt"/>
    <bpelx:inputProperty name="jca.file.TargetPhysicalDirectory" value="C:\FileRead2"/>
    <bpelx:inputProperty name="jca.file.TargetFileName" value="dummyCopy.txt"/>
    </invoke>
    And
    <invoke name="InvokeFileMove"
    inputVariable="InvokeFileMove_MoveFile_InputVariable"
    partnerLink="MoveFileService" portType="ns1:MoveFile_ptt"
    operation="Move" bpelx:invokeAsDetail="no">
    <bpelx:inputProperty name="SourcePhysicalDirectory" value="C:\FileRead"/>
    <bpelx:inputProperty name="SourceFileName" value="dummy.txt"/>
    <bpelx:inputProperty name="TargetPhysicalDirectory" value="C:\FileRead2"/>
    <bpelx:inputProperty name="TargetFileName" value="dummyCopy.txt"/>
    </invoke>
    These four properties are not visible in Invoke -> Properties tab as well.
    Could you please suggest how can I override the jca's values for FileIOInteractionSpec class?

    I have successfully used this API and it works fine.
    Try to use variables which contains values like "dummyCopy.txt" etc.
    Here is what I used :
    <bpelx:inputProperty name="jca.file.SourceDirectory"
    variable="inputDirectory"/>
    <bpelx:inputProperty name="jca.file.SourceFileName"
    variable="inputFileName"/>
    <bpelx:inputProperty name="jca.file.TargetDirectory"
    variable="destinationDirectory"/>
    <bpelx:inputProperty name="jca.file.TargetFileName"
    variable="inputFileName"/>
    Pass approppriate values into the above given variables and try.
    Hopefully it should work.
    Let us know, how it goes !
    <Puneet/>

  • Problem moving files using applescript/folder action setup.

    I'm wanting files to move to certain folders depending on what the first letter of the file name. Here is what I have so far. If the file starts with TF715SH it should move to Serenity:Color Images for Monthly:T
    property dialog_timeout : 30 -- set the amount of time before dialogs auto-answer.
    on adding folder items to this_folder after receiving added_items
        try
            tell application "Finder"
                repeat with this_item in added_items
                    if this_item starts with "M" then
                        move this_item to "Serenity:Color Images for Monthly:M:" with replacing
                    end if
                    if this_item starts with "N" then
                        move this_item to "Serenity:Color Images for Monthly:N:" with replacing
                    end if
                    if this_item starts with "T" then
                        move this_item to "Serenity:Color Images for Monthly:T:" with replacing
                    end if
                end repeat
            end tell
        end try
    end adding folder items to

    Hi,
    Because the class of this_item is a alias wich contains the full path of the file :
    You need to get the file name, also you must use the term "folder" before the string "Serenity:Color Images for Monthly:M:", otherwise the Finder will return an error.
    if (name of this_item) starts with "M" then
          move this_item to folder "Serenity:Color Images for Monthly:M:" with replacing
    end if
    Here's another way to do this :
    on adding folder items to this_folder after receiving added_items
          tell application "Finder"
                set colorImgFolder to folder "Serenity:Color Images for Monthly:"
                repeat with this_item in added_items
                      set c to first character of (get name of this_item)
                      considering case -- case sensitive
                            if c is in "MNT" then move this_item to folder c of colorImgFolder with replacing
                      end considering
                end repeat
          end tell
    end adding folder items to

  • HOW TO TRANSFER FILE USING SOCKET

    HI....
    My project is backup sever
    I want to take backup of any number of file and of any size please tell
    me solution how i can do this for this i done the zip file of backup.
    I done this but i face some problem...
    regards
    Ahire sharad

    ahire, if what you want is to transfer a file over a socket here's an example of a sender. If you need the reciever code too, let me know.
    public void run()
              FileInputStream inFile = null;
              try
                   Boolean done = false;
                   int inByte;
                   inFile = new FileInputStream(filename);
                   byte[] byteBuffer = new byte[128000];
                   while(!done)
                        inByte = inFile.read(byteBuffer, 0, byteBuffer.length);                         
                        if (inByte == -1)
                             done = true;
                        else
                             out.write(byteBuffer, 0, inByte);
                   inFile.close();
              catch (Exception e)
                   try {inFile.close();}
                   catch (Exception ex) {ex.printStackTrace();}
                   try{Thread.sleep(10);}catch(Exception ex){}
                   JOptionPane.showMessageDialog(null,"Error sending file " + filename + "\nError: " + e.toString(),"Error", JOptionPane.ERROR_MESSAGE);
         }Pd: As I see your english isn't so good... I can help you in spanish or italian too... just let me know. Regards,
    Message was edited by:
    doy2001

  • 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

  • I moved files off my computer to an external hard drive now time machine won't back up like it used to.  It says there is not enough room.

    My hard drive was completely full (mostly with pictures) so I moved several years worth of photos from the hard drive to an external hard drive I regularly use with the laptop. (Basically my master copies of all my photos back to 1997)  I have always had Time Machine set up to back up both the laptop AND that external drive.  It's always worked seamlessly until I moved those files.  Time Machine has been full for a while now and regularly gives me a message that the oldest files will be deleted.  That's fine. 
    I don't understand why moving files from the laptop to the external hd would now cause the following message (not an exact quote): Time Capsule cannot complete backup.  You need 233 gb to backup and time capsule only has 107 gb available. If time capsule was already set to backup up both the laptop and the external hd, why would moving those photos from one hd to the other cause a space issue?  It should equal out.   And now when I look at the files on the time capsule, it only shows me a recent backup and a partial incomplete backup.  None of the older backups are visible anymore. I have not deleted anything directly from the time capsule so I'm thinking somehow the index got damaged.  How can I fix this?  The error message says to change the settings but I really don't know what settings to change.  Help!!

    It does not immediately delete the files that are missing.. it merely tries to backup the new files it has discovered on the external drive. Since you moved the files there, the backup at least for a while will contain both copies.. and that is why it doesn't have enough space to backup.
    Fixing the problem.. hmm pondini is the expert.. you should be able to delete the backup of the photos in existing backup.. there are instructions to do it.. but it is a very poor way to do things.
    Much better. .archive off the existing backup.. this is long and slow but worth it. you need a usb drive of the same size as the TC drive. Then erase the TC and start a fresh set of backups.
    The alternative is to use the USB drive as a new target.. but it is much slower than the TC internal drive.
    http://pondini.org/TM/12.html

  • I am having a problem moving files from a iMac  in location mac in another location.  I have tried using Dropbox and the Public folder in the i disc.  When I drag the files into dropbox they become alias' and I can't open them at the other end beca

    I am having a problem moving files from an imac in one location to an imac inanother location.  I have tried using Dropbox which is installed in both locations but when i drad a file ino yhe app it becomes an alias.  When I get to the other location it says I can't open the file because the " original application that created it is not present".  This is despite the fact that the app that created both files is installed in both computers.  If I use the Public folder in the idisc, when I get to the other location the file isn't there.  Am I forgetting to turn something on or off?  Should I manually sync the Public folder and if so how? Thanks
    Message was edited by: stephenfromdelray beach

    So now that's two of us.  Hopefully, someone has an answer. 

  • When moving a file using drag and drop, as I hover over the destination folder it no longer opens, so I can't drop the file into the folder.  Why?

    When moving a file using drag and drop, as I hover over the destination folder it no longer opens, so I can't drop the file into the folder.  Why?  I have a heirarchical embedded folder structure under \Documents.  Usually, as I drag the file to be moved over the various folders, they will blink twice, then expand/open to reveal contents (in Finder).  Now, when the file to be moved is held (hovering) over the destination folder, it will not blink or expand, so there's no place to drop the file.  If I release the mouse button, the file image disappears, showing that it is "going back to the place it came from", a.k.a. was not moved.  This just started happening.  I noticed it after upgrading to Mavericks.  Is this a bug or could anything else be causing this?

    As of today, Apple Support discovered during a remote support session with me that the same thing happens on their own system.  It is isolated to "Column View"; the Icon and List views in Finder behave correctly.  Issue is being escalated to engineering, and Apple will call to report status in a couple days.  In all likelihood, this is a bug that will need to be addressed in a future update.

Maybe you are looking for