How to copy a file from windows to linux using java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • akoymakoy
    New Member
    • Oct 2006
    • 42

    How to copy a file from windows to linux using java

    Good Day:
    as the title says i am creating a program that will copy a file from windows to a linux machine. any help would be appreciated. i tried looking for it on google but i dont see a real help.

    a sample code will be a huge help.. ive tried a few times but to no avail and im running out of ideas

    thanks in advance
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Open a Socket and copy the file as an InputStream.

    Comment

    • akoymakoy
      New Member
      • Oct 2006
      • 42

      #3
      Originally posted by r035198x
      Open a Socket and copy the file as an InputStream.
      Im sorry but i dont know what sockets are... pls help me..
      a link to a tutorial on socket programming might help.. or a sample code will extremely help..

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by akoymakoy
        Im sorry but i dont know what sockets are... pls help me..
        a link to a tutorial on socket programming might help.. or a sample code will extremely help..
        Take a step back: how are those two machines connected to each other? Can
        one machine 'see' the filing system of the other and/or vice versa? If so, you can
        simply copy the file from one FS (Filing System) to the other.

        If not, does that Linux machine run FTP (File Transfer Protocol)? If so you can
        use your FTP client on the other machine to transfer the file.

        Does a SMB ("Samba") server run on that Linux machine? If so you can go back
        to that step one again and simply copy the file.

        Does any service run on that Linux machine that accepts file names and data
        and creates a corresponding file and stores the data in there? If so you have to
        connect to that service and send it the name and content of your file. This
        usually involves sockets.

        Is there any wire connected between the two machines? If not, you're out of luck.
        Use a USB stick or even floppy disks then.

        kind regards,

        Jos

        Comment

        • akoymakoy
          New Member
          • Oct 2006
          • 42

          #5
          Originally posted by JosAH
          If not, does that Linux machine run FTP (File Transfer Protocol)? If so you can
          use your FTP client on the other machine to transfer the file.
          i guess it runs FTP (Linux)

          The machines are connected like this:

          im browsing through the web application through IE on a windows workstation

          the application is being hosted in a linux platform.

          The method im doing is to upload a file from the windows workstation to the linux workstation.

          *SCENARIO*
          i want to change the picture the front page displays (.../pic1.jpg) .. i then browse and upload a new picture from any terminal (windows for example) and copy it to the directory of the linux.

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            So your Linux machine has a web service available, i.e. the service probably
            listens to port 80 for requests. This is old time technology with its myriads of
            solutions. Google for "web upload file servlet" and see the results.

            kind regards,

            Jos

            Comment

            • akoymakoy
              New Member
              • Oct 2006
              • 42

              #7
              i would look into it thanks


              i would also get back here i f i get it done or not..

              Comment

              • akoymakoy
                New Member
                • Oct 2006
                • 42

                #8
                so far all i have seen are jar files that need to be bought or is only in trial versions... are there open / free web upload file servlet. ?

                Comment

                • JosAH
                  Recognized Expert MVP
                  • Mar 2007
                  • 11453

                  #9
                  Originally posted by akoymakoy
                  so far all i have seen are jar files that need to be bought or is only in trial versions... are there open / free web upload file servlet. ?
                  You didn't look close enough: this one is completely free and there are
                  many more where this came from.

                  kind regards,

                  Jos

                  Comment

                  • akoymakoy
                    New Member
                    • Oct 2006
                    • 42

                    #10
                    Good Day ,
                    Right now i used the uploadPackage.j ar that i found . If anyone is familiar on how to use this jar pls help me.
                    When i upload an image file of any type and upload it or copy it to another pc the image file is broken.. the image is distorted..

                    this is my configuration.t xt:

                    name=report3.jp eg
                    dir=c:\
                    log=c:\
                    max=100000000
                    extensions=
                    reply=/upload.jsp
                    error=/tryal.jsp
                    overwrite=1


                    the max variable is the only thing i think that i should tweak.. However when i changed it from 10000 to 100000000 .. the image gor better but still distorted...

                    is there anything i could do or is this jar file limited on a uploading a certain kind of file.?

                    If there are any more suggested jars to use.. pls do so...

                    As to the oreilly servlets.. im still trying to study how to use it... i saw the demo but i am in the process of making it to work.

                    Comment

                    Working...