File Transfer In Java Using Socket Programming

Apr 7, 2014

I have written a java code to transfer files from one server to another using the concept of socket programming. I got the codes from another java forum that meet my requirements. The program is said to transfer large sized files (like .mkv , .mprg movies) from one machine to another and can be used to transfer files of all formats. But after running the codes I found that the program is not able to transfer large sized files such as movies and even pdf of sizes 80mb or 111mb. When i transfer small sized files, it gets transferred and the output shows that. You can run the codes and observe it. But when i try to transfer large sized files, the program goes on running for hours. The large sized files are not getting transferred. The program has used bytebuffer but still this error occurs. The codes are as follows (I got them from this site [URL] ....)

**ClientMain.java**

import java.io.IOException;
import java.net.Socket;
public class ClientMain
{
private DirectoryTxr transmitter = null;
Socket clientSocket = null;

[Code] .....

1. ClientMain.java and DirectoryTxr.java are the two classes under client application.
2. ServerMain.java and DirectoryRcr.java are the two classes under Server application.
3. run the ClientMain.java and ServerMain.java simultaneously

Also specify the source directory, destination directory and host address of the machine in which server is running in the ClientMain.java (as per your computer). Here we are not specifying source file, instead a source directory or folder is specifying. So the entire files of source directory will be transferred.

View Replies


ADVERTISEMENT

File Transfer In Java Using Socket Programming

Apr 8, 2014

I have written a java code to transfer files from one server to another using the concept of socket programming. I got the codes from another java forum that meet my requirements. The program is said to transfer large sized files (like .mkv , .mprg movies) from one machine to another and can be used to transfer files of all formats. But after running the codes I found that the program is not able to transfer large sized files such as movies and even pdf of sizes 80mb or 111mb. When i transfer small sized files, it gets transferred and the output shows that. You can run the codes and observe it. But when i try to transfer large sized files, the program goes on running for hours. The large sized files are not getting transferred. The program has used bytebuffer but still this error occurs. The codes are as follows (I got them from this site [URL] ....)

**ClientMain.java**

import java.io.IOException;
import java.net.Socket;
public class ClientMain
{
private DirectoryTxr transmitter = null;
Socket clientSocket = null;

[Code] ....

Note that:-

1. ClientMain.java and DirectoryTxr.java are the two classes under client application.
2. ServerMain.java and DirectoryRcr.java are the two classes under Server application.
3. run the ClientMain.java and ServerMain.java simultaneously

Also specify the source directory, destination directory and host address of the machine in which server is running in the ClientMain.java(as per your computer). Here we are not specifying source file ,instead a source directory or folder is specifying.So the entire files of source directory will be transferred.

View Replies View Related

Where To Use Accept Routine In Socket Programming

Sep 2, 2014

i was reading my book when in a code,it used accept(),but it did'nt talk about it.would you explain to me where to use accept().(the chapter was about socket programming)

View Replies View Related

Socket Programming - Serve All Network Protocols

Jan 13, 2014

I am new to java. I want to create a socket that can serve all the network protocols. Can we make such type of socket in java.

View Replies View Related

File Transfer In Java Using Sockets

Apr 8, 2014

I have written a java code to transfer files from one server to another using the concept of socket programming. I got the codes from another java forum that meet my requirements. The program is said to transfer large sized files (like .mkv , .mprg movies) from one machine to another and can be used to transfer files of all formats. But after running the codes I found that the program is not able to transfer large sized files such as movies and even pdf of sizes 80mb or 111mb. When i transfer small sized files, it gets transferred and the output shows that. You can run the codes and observe it. But when i try to transfer large sized files, the program goes on running for hours. The large sized files are not getting transferred. The program has used bytebuffer but still this error occurs.

**ClientMain.java**
import java.io.IOException;
import java.net.Socket;
public class ClientMain

[code]....

Note that:-

1. ClientMain.java and DirectoryTxr.java are the two classes under client application.
2. ServerMain.java and DirectoryRcr.java are the two classes under Server application.
3. run the ClientMain.java and ServerMain.java simultaneously

Also specify the source directory, destination directory and host address of the machine in which server is running in the ClientMain.java(as per your computer). Here we are not specifying source file ,instead a source directory or folder is specifying.So the entire files of source directory will be transferred.

View Replies View Related

Can't Transfer Floating Number Matrix From MATLAB Bin File To Java Array

Mar 5, 2014

The problem is, the values are completely different than they are saved in MATLAB, and probably I need to shift the values after transforming them into byte arrays.My Java code which reads values of floating numbers from a MATLAB bin file as follows:

import java.io.*;
import java.io.File;
import javax.imageio.ImageIO;
import java.nio.ByteBuffer; // may be useful?
public class floatingNumberMatrixReader {

[code]....

View Replies View Related

Remote File Transfer

Dec 27, 2014

I want to write a java program which would do remote file transfer without using Byte array..how I can get sample code program??

View Replies View Related

File Transfer But Cannot Load In Its Launcher

Feb 3, 2015

Okay I am having a problem I wrote some code to transfer a file from my server when requested by the client. The problem is that when the file which is requested is transferred the file cannot be open in its respected file launcher when clicked. The File launcher throws back this msg "My Issue It request the File but after the File is requested and stored on the Client Machine when I Hit the File to be Launch adobe says the file "Adobe could not open the File for it is not supported file type or because the file as been damage"

So i have two pair sets of code for original coded by me. Original code i had first Server

import java.io.*;
import java.net.*;
public class SimpleFileServer {
public final static String FILE_TO_SEND = "c:/Users/Acer/Downloads/COAFlags.pdf"; // you may change this
public static void main(String args[]) {

[code]....

View Replies View Related

File Transfer Protocol Implementation

Mar 19, 2013

I have to write a code for File Transfer Protocol! It says that I only need to write code for client, but it also says that I have to run the program and send some files to server. I guess than I also need server side as well. I have to write my own classes, I cannot import some existing classes. I have to connect to the server with password and username and after that send some files to the server. I don't know anything about FTP. Can i maybe do this by Sockets and ports? I worked something with that.

View Replies View Related

File Empty When Attempt To Transfer Between Computers Using Sockets

May 26, 2014

I am working on a project with client/server relationship and I want the client to be able to transfer their personal music files over the socket. Every time I attempt to do it the file is created but it is empty.

Server code:

Java Code:

public class Server extends JFrame {
//===============================
// FIELDS
//===============================
// connection essentials
private ServerSocket server;
private Socket connection;

[Code] ....

View Replies View Related

File Transfer App - Create / Select Destination Folder

May 14, 2015

I'm currently new to java and I would just like to ask if Socket is sufficient for this file transfer app I'm planning to work on.

The specs are as follows:

~ Move/Copy Files of selected folder/s to a single folder(consolidating them) within the same machine and Network
~ File type will be specified on GUI and those specified will be the ones transferred
~ option to choose Move or Copy of files
~ ability to create/select folder of transfer destination

Here is an draft of what the GUI will look like.

View Replies View Related

How To Transfer Cipher - Encrypt A File And Decrypt It On Another Host

Jun 30, 2014

I want to encrypt a file and decrypt it on another host. For decryption on another host I guess I need to transfer the cipher... how can this be done? How can you write a Cipher to disk?Or am I completely on a wron track?

The following code is doing it already on one host:
 
package test;
import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.io.Serializable;import java.security.Provider;
import javax.crypto.*;import javax.crypto.spec.DESKeySpec;

[Code] ....

View Replies View Related

Send Text File Over Socket

Feb 18, 2014

I'm trying to send a text file over a socket, from client to server, but I doesn't work. I will demonstrate a part of the code that isn't working.

The critical part of the server look like this:

while(true) {
try {
Socket socket = fileSocket.accept();
out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String s = in.readLine();

And the client like this:

Socket = new Socket(address, number);
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(Socket.getOutputStream()));
BufferedReader in = new BufferedReader(new InputStreamReader(Socket.getInputStream()));
BufferedReader fileIn = new BufferedReader(new FileReader(filename));
String s = fileIn.readLine();
out.write(s);

Now I want the s in the server to hold the same string as s in the client, but the server can't read the stream - nothing happens. I know that readLine() reads until a new line character, but it doesn't word to write and read a single character either.

View Replies View Related

How To Send A File Without Closing The Socket

Mar 3, 2014

I wrote a program to transfer a file using tcp connection, where I closed socket since the receiver need to detect the end-of--file.  But now I like to extend it to multiple file for which i should not close the socket until all the files are send. I can't find a way for this. So how to resolve it.

View Replies View Related

Import From File Using Object Oriented Programming

Apr 12, 2013

How to import data from a file using Object Oriented Programing? I know how to write OOP Java and I know how to read data from a file in Procedural Java but would like to know more about how to do it OOP. Is it the same as reading data process as in Procedural programming?

View Replies View Related

JSF :: Transfer Value From JavaScript To Backingbean Java

Apr 30, 2014

I have a js code that finds out the timezone and then I am trying to "send" a value to a java backingbean. This code must be execute during the load of the xhtml page because in the process I use the "localTimeZone" bean.

<h:inputHidden value="#{localTimeZone.timeZoneID}" id="clientSelectedTimeZoneID"/>
<h:inputHidden value="#{localTimeZone.offset}" id="clientSelectedOffset"/>
<script type="text/javascript">
var userTimeZone = userTimeZone();

[Code] ....

How is the correct way to do this in order to have the setters of backingbean called ?

JSF ver: Implementation-Version: 1.2_12-b01-FCS
RICHFACES: Implementation-Version: 3.3.3.Final

View Replies View Related

Can Transfer Other Files With Jar Using Java Web Start?

Nov 15, 2014

I made a tiny app that saves notes to a folder within the classes directory where I created the .jar file.Let's say I wanted to add this to Java Web Start. Would I be able to transfer the jar file within a folder(s) or would I have to change the program so that It creates a new folder to save texts In automatically ? Basically , can jar files be transferred with other files/folders ?

View Replies View Related

UDP Server Programming In Java

Apr 15, 2015

The goal is as follows: Write a UDP 'CompressionServer' that will take input from the user until it sees a "magic string" at which time it will create a compressed and uncompressed version of the file in the file system.

So, I need to integrate the following "Zip" code in to my UDP server code (which already creates the uncompressed file)... That is where I am stuck at now. My first few attempts had the Zip code after I write to "fout" but that failed to create a ZIP file.

I guess the main point here is what are the key pieces of the ZIP code that I should include and what would be the best spot to place them in my server code...

Zip Code:

import java.io.*;
import java.util.zip.*;

public class Zip {
static final int BUFFER = 2048;
public static void main (String argv[]) {
try {
String fileInput = argv[0];
String fileOutput = argv[1];

[Code] ....

View Replies View Related

Java Programming - Coins In A Jar

Apr 3, 2014

We are working with Java and Eclipse..One of the assignments asks to "Write an application that determines the number of coins in a jar and prints out the total in dollars and cents. Read integer values that represents the number of quarters, dimes, nickels and pennies. Use a currency formatter to print the output."

View Replies View Related

Programming With Fingerprint SDK Java

May 1, 2014

I would like to bring a project in java program written by me, that interfaces with a fingerprint reader (already purchased, the reader U.are.U 4000b) and as I'm using fingerprint sdk sdk's Griaule.

View Replies View Related

Use Java Programming For Image Processing

Feb 12, 2015

can we use java programming for image processing. if yes then how do we do it?

View Replies View Related

Java Programming Project Involving Get And Set Methods?

Apr 4, 2014

1. Modify the following class so that the two instance variables are private, there is a constructor that accepts both the player's name and sport and there are get and a set methods for each instance variable:

public class Player {
String name;
String sport;
}

2. You can pass an instance of this class to the JLabel constructor if you want to display text in the label.Select one:
a. myLabel
b. myText
c. String
d. JTextField
e. JLabelText

how to start making this work?cause i am not familiar with the terms here and want to complete this program and I am new to java programming?

View Replies View Related

Test Arithmetic Java Programming Error

Oct 13, 2014

I have written this program but I am seeing error when I compile this program ( javac TestArithmetic.java).

1)TestArithmetic.java:26 cannot find symbol

2)symbol: class Arithmetic

3)location: class TestArithmetic

4) Arithmetic ar = new Arithmetic(x1,x2,x3);

1)TestArithmetic.java:26 cannot find symbol

2)symbol: class Arithmetic

3)location: class TestArithmetic

4) Arithmetic ar = new Arithmetic(x1,x2,x3);

2 errors.

Code :

import java.util.*;
class TestArithmetic {
public static void main (String[] args){
float number;
Scanner console= new Scanner (System.in);
System.out.println("Enter first number");

[Code] .....

View Replies View Related

Filters Java Programming - Determine If Integer Is Not Divisible By Some Value

Apr 10, 2014

I am new to java and do not understand how to use filters very well. I need to write a code that determines if an integer is not divisible by some value. A filter also contains an upstream filter so that this filter can be part of a chain of filters.

View Replies View Related

Java Programming - Remove Words That Begin With Two Consonant

Jun 11, 2014

Remove the words that begin with two consonants.

View Replies View Related

Java Programming To Input Number And Display All Its Prime Digit?

Jan 9, 2015

I am new to java programming and using bluej for programming and i have tried this question what i have have given in title ... how to find out the errors in the following program:-

class Primedig {
public void getinput(int n) {
int ctr=0;
while(n!=0) {
int r=n%10;
for(int i=1;i<=r;i++)

[code] .....

output:-

For example input is 243 the output comes only 3 not 2& 3 both.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved