473,386 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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
Jul 3 '08 #1
9 9944
r035198x
13,262 8TB
Open a Socket and copy the file as an InputStream.
Jul 4 '08 #2
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..
Jul 6 '08 #3
JosAH
11,448 Expert 8TB
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
Jul 6 '08 #4
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.
Jul 6 '08 #5
JosAH
11,448 Expert 8TB
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
Jul 6 '08 #6
i would look into it thanks


i would also get back here i f i get it done or not..
Jul 8 '08 #7
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. ?
Jul 9 '08 #8
JosAH
11,448 Expert 8TB
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
Jul 9 '08 #9
Good Day ,
Right now i used the uploadPackage.jar 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.txt:

name=report3.jpeg
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.
Jul 17 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Hal Vaughan | last post by:
I want to have a config file for my program, which means I need to know where the config file is. If I type: java myclass and it runs myclass.class, is there any way to obtain the location of...
4
by: inquirydog | last post by:
Hello- I, the inquirydog, would like to solicit suggestions for a new web page I am making: I am creating a simple website that will translate concepts between windows os's, Linux, and the...
48
by: Joseph | last post by:
Hi I'm writing a commercial program which must be reliable. It has to do some basic reading and writing to and from files on the hard disk, and also to a floppy. I have foreseen a potential...
12
by: Von Clubusev | last post by:
I like Java just as much as I like C#, but the truth is that unless you absolutely need platform portability, DotNet is the way to go. This is becoming even more true with the release of Windows...
3
by: Igor.Smirnov | last post by:
Hi, Why g++ in Linux does not call copy constructor at return statement? I have detected this at Sicentific Linux 4.1 (g++ v. 3.4.3) and Red Hat Linux 8.0 (g++ v. 3.2). Microsoft Visual...
3
by: muquaddim | last post by:
Hi, First of all I am not a java programmer. what I am doing is just trying to port a precompiled game to other machine. I have a java game project. the final output or the game is "game.jar". I...
5
by: ganeshp | last post by:
Hi , In Java using socket programming is it possible to have a server program on windows that services a client program on linux? I tried the code in the below given link:...
1
by: RolfK | last post by:
Hello Experts, I have a small problem with copy of CDATA sections. (I'm using XSLT2.0 ) My output target is defined as txt. In my xml source is a CDATA section to be put as it is into the...
11
by: isaacrc82 | last post by:
Hi every body: An exception is thrown when I open some files in linux, this doesn't occurrs when I do the same in windows XP. This is the pierce of code that throws the exception: 42 ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.