title: URL Connection (FTP) in Java - Simple Question
body: <p>I have a simple question. I'm trying to upload a file to my ftp server in Java. </p>
  
  <p>I have a file on my computer, and I want to make a copy of that file and upload it. I tried manually writing each byte of the file to the output stream, but that doesn't work for complicated files, like zip files or pdf files.</p>
  
  <pre><code>File file = some file on my computer;
  String name = file.getName();
  URL url = new URL("ftp://user:password@domain.com/" + name +";type=i");
  URLConnection urlc = url.openConnection();
  OutputStream os = urlc.getOutputStream();
  
  //then what do I do?
  </code></pre>
  
  <p>Just for kicks, here is what I tried to do:</p>
  
  <pre><code>OutputStream os = urlc.getOutputStream();
  BufferedReader br = new BufferedReader(new FileReader(file));
  String line = br.readLine();
  while(line != null &amp;&amp; (!line.equals(""))) {
      os.write(line.getBytes());
      os.write("\n".getBytes());
      line = br.readLine();
  }
  os.close();
  </code></pre>
  
  <p>For example, when I do this with a pdf and then try and open the pdf that I run with this program, it says an error occurred when trying to open the pdf. I'm guessing because I am writing a "\n" to the file? How do I copy the file without doing this?</p>