File transfer using tcp that  implements in swing

Can anybody send me the file transfer using tcp that implements in swing codes

I'm assuming that you're inputing a plain ASCII text SQL file. It's easier to use Readers if you're dealing with plain text, the Output and Input Streams are for Byte input and output. So:
BufferedReader myReader = new BufferedReader(new FileReader("myFile.sql"));
BufferedWriter myWriter = new BufferedWriter(new InputStreamWriter(mySocket.getInputStream()));
String inString;
while((inString = myReader.readLine()) != null)
myServerWriter.write(inString);
myServerWriter.writeLine();
myServerWriter.flush();
Then, in the server you can use the same method that I'm using for the Buffered Reader to read in the file, and use a BufferedWriter wraped around a FileWriter to output the text to that file. Bravo.
-Jason Thomas.

Similar Messages

  • I woke up at 3am to find my MacBook Pro in the middle of a file transfer using AirDrop.

         I woke up at 3am to find my MacBook Pro in the middle of a file transfer using AirDrop. I had not accepted any file transfers via AirDrop as I was asleep so I am a bit confused by all the posts that say that the only way it will work is by the end user accepting a request to transfer files. I am on a home network which has both a soft and hard firewall. I checked my firewall logs and have no signs of intrusion or intrusion attempts. I checked my network map to see see if someone had brute forced my router and was using it but the only assets listed were mine. My router is set up to not be accessable from wireless computers, and is filtered to only allow use by a assets in the MAC Address list. I am an IT by trade but this is my first mac so I am not completely savy in the ways of the ways of macdom. I have found several posts with suggestions on how to turn off and came up with the following terminal command "defaults write com.apple.NetworkBrowser DisableAirDrop -boolean YES". My question is this, how is it possible that my AirDrop was activated and in the middle of a file tranfer if I did not initiate it? I do have a MacMini on my network but its WiFi is turned off so the transfer was not with it. I have read on different posts that you cannot AirDrop if the computer is not on the same network but there were no foreign assets on my network. So my question is this
    1. If AirDrop can not be used with another computer if it is not on the same network, how was it being used?
    2. How can AirDrop be used to xfer files if I did not accept or initate it?
         It seems to be a pretty big security hole to me. Any suggestions or help would be greatly appreciated.
    Ethan

    It could just be a bad disc - I use Verbatim and have only had one fail in a ten-year time period. Try getting a batch of Verbatims and see if you have any problems. I didn't even know that there were Kodak branded discs...
    Clinton

  • HT204144 File transfer using Airdrop from iphone to Macbook Pro

    File transfer using airdrop form Macbook Pro to iphone is working...but from iphone to Macbook Pro is not working, Why?

    Hi Brok25;
    Thanks for the question.  The resource below explains the specs and settings that are needed for AirDrop.  Check the settings and look to see if your MacBook Pro is listed.
    Mac Basics: AirDrop lets you send files from your Mac to nearby Macs and iOS devices - Apple Support
    http://support.apple.com/en-us/HT203106
    Sending files to and from an older Mac
    If a Mac you're using with AirDrop was manufactured before 2012, you can send and receive files with other Mac computers.
    On the sending Mac, click "Don't see who you're looking for" in the AirDrop window.
    Select the option to "Search for an Older Mac."
    On the receiving Mac, open a new Finder window and click AirDrop in the sidebar.
    Tips for sending files
    Make sure Wi-Fi and Bluetooth are enabled on your Mac and your iOS device. Although you don't have to connect to a specific network, Wi-Fi needs to be on to send and receive files using AirDrop.
    Move your devices closer together. AirDrop is designed to work within a range of approximately 30 feet (9 meters). If you need to send a file to someone farther away, consider using File Sharing, iCloud, or email instead.
    If you're using a firewall on your Mac, you won't be able to receive AirDrop files if you have enabled "Block all incoming connections" in the Security & Privacy pane of System Preferences.
    Make sure your devices meet system requirements for AirDrop.
    System Requirements
    To see if your Mac works with AirDrop, make sure you’re in the Finder by clicking the desktop (the background area of your screen), or by clicking the Finder icon in the Dock. Then, check to see if AirDrop is listed as an option in the Go menu. If you don't see AirDrop listed, your Mac doesn't support this feature.
    In order to transfer files between a Mac and and an iPhone, iPad or iPod touch
    your iOS device needs to include a lightning connector 
    your iOS device needs iOS 7 or later installed
    your Mac needs to be a 2012 or later model with OS X Yosemite installed
    Your Mac and iOS device both need bluetooth and Wi-Fi turned on. You do not have to be connected to a specific Wi-Fi network. 
    To transfer files between two Mac computers, you need the Mac models listed below with Wi-Fi turned on and OS X Lion or later installed.
    MacBook Pro (Late 2008 or newer)*
    MacBook Air (Late 2010 or newer)
    MacBook (Late 2008 or newer)*
    iMac (Early 2009 or newer)
    Mac Mini (Mid 2010 or newer)
    Mac Pro (Early 2009 with AirPort Extreme card, or Mid 2010)
    *The MacBook Pro (17-Inch Late 2008) and the white MacBook (Late 2008) do not support AirDrop.
    For help identifying your Mac, choose About This Mac from the Apple menu. You can refer to the Apple Support website to find out if your iPhone, iPad or iPod Touch includes a lightning connector. 
    Cheers,
    - Judy

  • WebUtil file transfer in multiple user implementation

    Hi
    Installed WebUtil and able to integrate forms/reports in Web enviroenment 10gAs.
    Around 30 to 40 people will use this application, Now to do client side integration (To Save generated output to Cleint m/c) we are geerating file on AppServer and transferring using Webutil file transfer but my question if multiple users running same report from form and generates two different date ranges to generate to same file on Appserver, How Can I use WebUtil file tranfer for two people running same report. Is that going to be problem in concurrent user environment.
    Setup 10gAs, User A select report A and run with two different data ranges and file saved on Appserver as test.pdf and now user b want to run same report with time range little bit different time range and file has to be saved to same test.pdf on ApopServer, Now how oracle going to handle this ???????.
    Pl answer this is very important as we are running this reports in Web implementation with more than 30 users.
    Many thanks in advance.
    Murthy

    Surely the real issue is that you are always generating to the same filename? Incorporate an identifier into the filename. e.g. the username
    Regards,
    Robin Zimmermann

  • File transfer using internet tool kit

    HI 
    i just need to do simple file transfer between 02 pcs connected over a network ....... i am using the internet toolkit .... i have seen the shipped example FTP browser.vi but i am not quite sure how to work with it .
    consider that i have only to pc's one with ip add 192.168.0.1 and other with 192.167.0.2.... and i want to transfer a file form one to another or vice-versa.....
    Also i came across that to use ftp vi's i should have guideftp(ftp server) installed on my pc (http://zone.ni.com/devzone/cda/tut/p/id/3534). what the purpose of using this server??
    and how can i achieve the simple task of sending a file from one pc to the other using labview?
    regards  
    Regards

    nolsqn wrote:
    Also if someone can explain me how to use the guideftp (ftp server ) with the internet toolkit ?
    thanks 
    The FTP VIs in the internet toolkit implement a FTP client. The FTP protocol is a client/server protocol. In order to use the FTP VIs there needs to be a FTP server for it to connect to. That is the purpose that the guideftp tool you mention is providing.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Data loss in the secure file transfer using java

    Hi,
    My java Appllication uses the sftp(secure file transfer protocol) for file transferring. when the load is high like 150 GB , data loss occuring for some files especially last chunk of data is missing.
    Core file transfer code
    while (true)
    int read = bis.read(buffer); //Reading bytes into the byte array (buffer) from network stream (bis).
    if (read==-1) {
    break; //Break the loop, if there are no more bytes available in the InputStream.
    bos.write(buffer,0,read); //Writing the same number of bytes what we read into buffer byte array into OutputStream
    complete.update(buffer,0,read); //Giving the same number of bytes what we read above to the checksum calculation.
    bytesSoFar += read; //Incrementing the bytes that we have read from the source.
    //if the bytes transferred are equal to the source file size
    If (bytesSoFar == fileInfo.getFileSize().intValue())
    // Calculate the file checksum.
    // Update DbAuditLog with checksum and no. of bytes read
    else
    // Update DbAuditLog with no. of bytes read
    bos.flush();
    Please help , why the data loss is happening when the big size files transfer
    Note:
    1.150 gb not a single file multiple files.
    2.SFTP no java specific API, So connection is happening through java .io.sockect connection

    so, if you are not getting any exceptions, yet the data is incorrect, it sounds like you are having actual network issues. i'd start looking at things like the actual network cards in the computer as well other equipment involved in the transfer. since you are not getting exceptions, the network stack obviously thinks nothing was lost over the wire, so either the actual hardware has issues, or the network stack, or the issue is on the sending end. the last possibility is that the client is somehow munging the data it is sending. do you control the client code? if so, i'd start checking the client side code for bugs (and/or post it here).
    also, i'm assuming that all of the variables included in your original code are thread local (you aren't sharing any of those buffers/streams/etc between multiple threads).

  • Binary file transfer using RMI

    Thanx in advance !!!
    My Query:
    Is there any restriction on the maximum size of a binary file that can be transferred over RMI?
    In an application (and as per the requirements), I am converting the file contents to a byte array on the client machine and transferring using RMI method calls. At the server side, I am reconstructing the file using the same byte array.
    Writing a Java FTP application is out of question.
    So please advise.
    Vikas

    RMI uses TCP/IP so the default should be close to the standard IP limit.

  • Plz hel for file transfer using zmodem protocol

    someoe plz help me. i have to devlop an application that transfers files betwn 2 pcs(both ways) using dial up connection, further it should autodial the connection at periodic times.
    i am trying to use Zmodem file transfer protocol. i succseed in sending string (for test)using my sender program with hyper terminal open on the other hand. it prints the string. but when i use my receive program, similar to given in samples(simpleread.java) it doesnt work.
    actually when the ring comes from the sender how to send command to modem to hang up and connect to the calling pc if there are any such commands then plz help.
                                  ----sameer

    someoe plz help me. i have to devlop an application
    that transfers files betwn 2 pcs(both ways) using dial
    up connection, further it should autodial the
    connection at periodic times.
    i am trying to use Zmodem file transfer protocol. i
    succseed in sending string (for test)using my sender
    program with hyper terminal open on the other hand. it
    prints the string. but when i use my receive program,
    similar to given in samples(simpleread.java) it doesnt
    work.
    actually when the ring comes from the sender how to
    send command to modem to hang up and connect to the
    calling pc if there are any such commands then plz
    help.
    ----sameerU ddnt abrvt nuf. I r3r1t 4 U.
    Sum1 plzz hep m3. i 1/2 2 dvlop app taht xfer fil betwn 2 pcs(bth wys)...

  • File transfer using non-blocking sockets - data mysteriously  vanish

    Hello,
    I need to pass some big amount of data using sockets. I my appliaction I have noticed that sometimes I didn't get all bytes. To check it out I wrote simple client + server to figure out what is happening. So:
    - I have a sender and receiver application
    - I'm trying to transfer 5MB text file.
    - On receiver side, output file is never larget than 3MB
    - If I put some timeout on sender side (1ms timeout between write operations) everything works fine.
    Could someone tell me what I do wrong? Why data disappears and when? The same file transfered using old sockets goes always fine...
    Thanks in advance!
    Here is complete source for receiver and sender:
    RECEIVER:
    import java.io.FileOutputStream;
    import java.net.InetSocketAddress;
    import java.nio.ByteBuffer;
    import java.nio.channels.SelectionKey;
    import java.nio.channels.Selector;
    import java.nio.channels.ServerSocketChannel;
    import java.nio.channels.SocketChannel;
    import java.util.Iterator;
    public class ReceiverA {
          * @param args
         public static void main(String[] args) {
              String outputFile = "c:\\outputA.txt", host = "127.0.0.1";          
              int port = 8001, bufferSize = 10240;
              try {
                   ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
                   Selector selector = Selector.open();
                   ServerSocketChannel server = ServerSocketChannel.open();
                   server.configureBlocking(false);
                   server.socket().bind(new InetSocketAddress(host, port));
                   server.register(selector, SelectionKey.OP_ACCEPT);
                   System.out.println("Server started");
                   while(true)
                        selector.select();
                        Iterator<SelectionKey> iterator = selector.selectedKeys().iterator();
                        while (iterator.hasNext()) {
                             SelectionKey key = (SelectionKey) iterator.next();
                             iterator.remove();
                             if (key.isAcceptable()) {                              
                                  SocketChannel client = server.accept();
                                  client.configureBlocking(false);
                                  client.register(selector, SelectionKey.OP_READ);                              
                                  continue;
                             SocketChannel channel = (SocketChannel) key.channel();
                             int counter = 1;
                             if ( key.isReadable() ) {
                                  FileOutputStream os = new FileOutputStream(outputFile);
                                  int res;
                                  do
                                       buffer.clear();
                                       res = channel.read(buffer);
                                       counter += res;
                                       System.out.println(res);
                                       buffer.flip();
                                       os.write(buffer.array(), 0, buffer.limit());
                                  while( res >= 0 );          
                                  channel.close();
                                  os.close();          
                                  System.out.println("Receiver: " + counter);
                                  return;
              } catch (Exception e) {
                   e.printStackTrace();
    }SENDER:
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.net.InetSocketAddress;
    import java.nio.ByteBuffer;
    import java.nio.channels.SelectionKey;
    import java.nio.channels.Selector;
    import java.nio.channels.SocketChannel;
    import java.util.Iterator;
    public class SenderA {
         public static void main(String[] args) {
              String inputFile = "c:\\inputA.txt" , host = "127.0.0.1";          
              int port = 8001, bufferSize = 10240;
              try {
                   ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
                   byte[] byteArr = new byte[buffer.capacity()];
                   Selector selector = Selector.open();
                   SocketChannel connectionClient = SocketChannel.open();     
                   connectionClient.configureBlocking(false);
                   connectionClient.connect(new InetSocketAddress(host, port));
                   connectionClient.register(selector, SelectionKey.OP_CONNECT);
                   while(true) {
                        selector.select();
                        Iterator<SelectionKey> iterator = selector.selectedKeys()
                                  .iterator();
                        while (iterator.hasNext()) {
                             SelectionKey key = (SelectionKey) iterator.next();
                             iterator.remove();
                             SocketChannel client = (SocketChannel) key.channel();
                             if (key.isConnectable()) {
                                  if (client.isConnectionPending()) {
                                       System.out.println("Trying to finish connection");
                                       try {
                                            client.finishConnect();
                                       } catch (IOException e) {
                                            e.printStackTrace();
                                  client.register(selector, SelectionKey.OP_WRITE);
                                  continue;
                             if(key.isWritable()) {
                                  FileInputStream is = new FileInputStream(inputFile);
                                  int res;
                                  int counter = 0;
                                  do
                                       buffer.clear();
                                       res = is.read(byteArr, 0, byteArr.length);                                   
                                       System.out.println(res);
                                       if ( res == -1 ) break;
                                       counter += res;
                                       buffer.put(byteArr, 0, Math.min(res, buffer.limit()));
                                       buffer.flip();
                                       client.write(buffer);
                                        * When I remove comment file transfer goes OK!
                                       //Thread.sleep(1);
                                  while( res != -1 );          
                                  client.close();
                                  is.close();          
                                  System.out.println("Receiver: " + counter);
                                  return;
              catch(Exception e) {
                   e.printStackTrace();
    }

    There are at least two problems here.
    A. In the receiver you should test for -1 from the read() immediately, rather than continue with the loop and try to write -1 bytes to the file.
    B. In the sender you are ignoring the return value of client.write(), which can be anything from 0 to the buffer length. If you get 0 you should wait for another OP_WRITE to trigger; if you get a 'short write' you need to retry it until you've got nothing left to write from the current buffer, before you read any more data. This is where the data is vanishing.

  • File to file transfer using UDF

    Hi
      i am doing one scenario,file tofile transfer using UDF.
    I will write one UDF which will read the whole content from text file and write to the target path.Ok.so i am mentioning both sender and reciver URL in UDF.is this the correct way.
    then if am writing URL in UDF then is it again need to create  communication channel for both.
    and how i will do mapping  using UDF..plz let me know  weather my concept is correct or not

    Hi,
    You can do this with out UDF and through File--File Simple Scenario
    What is your Typical requirement to use the UDF here.
    If there is no Specific UDF Requirement means , we can follow Normal Scenario to pick the file from One place and to place it at another folder
    File to File scenario:
    Introduction to simple(File-XI-File)scenario and complete walk through for starters(Part1) - File to File Part 1
    Introduction to simple (File-XI-File)scenario and complete walk through for starters(Part2) - File to File Part 2
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/xi/flatFILETOFLATFILE&
    REgards
    Seshagiri

  • File transfer using WIFI

    When I'm connected to my PC for WIFI file transfer. The program does not MAP to my hard drive

    Make sure AP isolation on router is Off
    Also you need file andwireless sharing enabled in PB settings  Storage and Sharing. 
    Then go to settings,  wifi, and ? info icon, then Internet Connection dropdown to get PB ip address...
    192.168.xxx.xxx
    Map drive in My Computer to \\192.168.xxx.xxx\media
    That should be all you need to do.

  • Canon Raw File Transfer using Canon 7D / Lion / Aperture 3.2

    Is anyone finding issues in unloading raw files with a Canon camera and the latest software?  I have been doing this successfully for some time using Aperture 3.1 with Snow Leopard.  I use a 13" MBP with 8GB of memory and a huge hard drive.  I upgraded to Lion and Aperture 3.2 and find that my Canon 7D doesn't transfer all of my pictures off of the camera.  The camera is connected via the USB cable that plugs directly into the camera.  I have found a workaround by re-importing off the camera and selecting the option to not download previously imported pictures.  Depending on the number of photos, I may have to do it up to 10 times to get all the pictures.  I have the latest Canon 7D firmware.  I'm able to successfully do this using Canon Utilities running on Lion.  Ironically, this same issue happens when I import into Aperture from the camera or from the hard drive.  After importing onto my hard drive using Canon software and getting all the pictures in one try, I then tried to import from the hard drive into Aperture but faced the same issue.  I think I have this isolated to an Aperture 3.2 issue with Lion and Canon 7D raw images.  I also thought that it might be due to lack of battery life on the camera or with large photo shoots.  Nope.  It happens as well with a small number of photos and a healthy battery.
      Is anyone else running into this issue?  Thanks.

    The Digital Camera RAW Compatibility Update 3.9:
    http://support.apple.com/kb/DL1473
    supports Powershot S100, try to download and install this update.
    Regards
    Léonie

  • Webservices for file transfer using XI

    Dear all,
    I want to transfer 30gb of different files to my target system.
    Here no mapping is involved.
    can i use Webservices like megaupload etc,to upload the same using XI.
    If so kindly clarify ,how do I achieve the same.
    Thanks,
    Srinivasa

    refer  this thread
    Re: Large file handling issue
    Re: Java proxies for handling large files
    Does SAP XI (PI 7.0) support streaming to support large file/Idoc
    hope it will solve ur querry
    Thanks!!

  • File transfer using wireless network

    Hi all
    Is it possible to add my 5800 to my home network as a device so I can share files etc. The phone connects automatically for internet access but that's not what I want to do.
    Hope this makes sense.

    Hi arkwright617 - yes what you say does make sense, and unfortunately I can't give you a clear yes or no answer as you'd have to try a couple of things to see whether it will work.
    Just a bit of background so you know where I'm coming from - Some Nokia phones (like the N95) support a technology called UPnP which allows the filesharing you mention to take place relatively easily and painlessly - unfortunately the 5800 doesn't support this technology.
    I've had a look at the technical specification of your phone, and it mentions that you have WiFi, but 3G only and I'm not sure exactly what that means - but if it means for example that you can surf the internet (from your phone) connecting via your wireless router rather than your mobile network provider then this is good and we can progress - otherwise it'll definitely be a no go (although you can still transfer files via cable if required you won't be able to do it wirelessly)
    If you can surf the internet from your phone, then you will have to run a piece of software on your PC called a Web server - what you can then do is point your web browser on your phone to your PC and you can then download any files you require to your phone.
    There are a couple of VERY VERY VERY important provisos you need to be aware of before doing this :
    1) Although you will be able to download files from your PC, if you misconfigure your web server then everyone else on the internet could potentially do so too - be very very very careful before going down this road.
    2) Even just installing web server software onto your PC could open it up to attacks from the internet - so be very very very careful.
    Regards,
    Edward

  • Pdf file transfer using ftp in java

    Hi,
    I am tried to get a pdf file from ftp. I am using the following code. This code works fine with .txt files but not with .pdf files. The pdf file generated is empty.
    import java.awt.Desktop;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import org.apache.commons.net.ftp.FTPClient;
    public class FTPConn {
           public static void main(String[] args) throws FileNotFoundException {
            FTPClient f = new FTPClient();
            try {
                f.connect(ip);
                f.login("username", "password");
                File dir = new File("dir");
                dir.mkdir();
                File myFile = new File(dir, "myfile19.pdf");
                myFile.createNewFile();
                FileOutputStream fout = new FileOutputStream(myFile);
                String content= fout.toString();
                boolean success = f.retrieveFile("/location on ftp/ftp.pdf", fout);
                System.out.println("Content :"+content);
                if (success) {
                    fout.flush();
                    fout.close();
                } else {
                    System.out.println("Reterive failure");
                Desktop d = Desktop.getDesktop();
                d.open(myFile);
            }catch(Exception e){
                e.printStackTrace();

    Hi,
    I am tried to get a pdf file from ftp. I am using the following code. This code works fine with .txt files but not with .pdf files. The pdf file generated is empty.
    import java.awt.Desktop;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import org.apache.commons.net.ftp.FTPClient;
    public class FTPConn {
           public static void main(String[] args) throws FileNotFoundException {
            FTPClient f = new FTPClient();
            try {
                f.connect(ip);
                f.login("username", "password");
                File dir = new File("dir");
                dir.mkdir();
                File myFile = new File(dir, "myfile19.pdf");
                myFile.createNewFile();
                FileOutputStream fout = new FileOutputStream(myFile);
                String content= fout.toString();
                boolean success = f.retrieveFile("/location on ftp/ftp.pdf", fout);
                System.out.println("Content :"+content);
                if (success) {
                    fout.flush();
                    fout.close();
                } else {
                    System.out.println("Reterive failure");
                Desktop d = Desktop.getDesktop();
                d.open(myFile);
            }catch(Exception e){
                e.printStackTrace();

Maybe you are looking for

  • How do I select a sloft cover book when ordering an iphoto book?

    I have put together an iphot book. When I went to order it in print form, there was no place to select it as a soft cover book. How do I do this?

  • Modifying destination Directory of Application server for Open Hub

    Hi All, i want to load a csv file on application server using Open Hub. when i have created the open hub i have specified the server name, the file name and the directory. but the Basis guys told me that i should use another directory, they have crea

  • Error  "expected a myfaces custom component class in package"

    Can anybody help me on this? just copied the sandbox code on selectmanypicklist and tried in a separate package of mine. created a jsp page and used the selectmanypicklist component and im getting the component on my browser. But whn i added the java

  • Elements 13 slows to a crawl when Organizer is running on IMAC

    I am running on a 4GHz Retina IMAC with 32GB RAM and i constantly get the spinning BBOD overtime I try to edit or save pictures when  is Organizer is running in the background.  The BBOD eventually goes away but the delays are so long it impossible t

  • Members order in Dataform

    Hi gurus, My user needs the dataform structure to be top down in rows(Like dimension hierarchy structure in outline). How could i accomdate that in dataform, please help me out on dis. Also how can i hide the POV dimensions because the user needs run