Note that there are some explanatory texts on larger screens.

plurals
  1. POException while uploading file to FTP Server
    primarykey
    data
    text
    <p>What I am trying to do is to upload a simple text file to the FTP Server using java code but getting error. I am trying hard to make it work but not able to do that. Below is the code.</p> <pre><code> File file = new File("testFile.txt"); FileOutputStream fo = new FileOutputStream(file); PrintStream ps = new PrintStream(fo); ps.println("BLA"); ps.close();`enter code here` fo.close(); uploadFile(file,file.getName()); public void upload( String ftpServer, String user, String password, String fileName, FileInputStream is ) throws MalformedURLException, IOException { log("inside upload..........."); if (ftpServer != null &amp;&amp; fileName != null &amp;&amp; is != null) { StringBuffer sb = new StringBuffer( "ftp://" ); // check for authentication else assume its anonymous access. if (user != null &amp;&amp; password != null) { sb.append( user ); sb.append( ':' ); sb.append( password ); sb.append( '@' ); } sb.append( ftpServer ); sb.append( '/' ); sb.append( fileName ); /* * type ==&gt; a=ASCII mode, i=image (binary) mode, d= file directory * listing */ sb.append( ";type=i" ); BufferedInputStream bis = null; BufferedOutputStream bos = null; try { URL url = new URL( sb.toString() ); URLConnection urlc = url.openConnection(); log("urlc::1 "+urlc); bos = new BufferedOutputStream( urlc.getOutputStream() ); log("bos:: "+bos); bis = new BufferedInputStream( is ); int i; // read byte by byte until end of stream while ((i = bis.read()) != -1) { log("i"+i); bos.write( i ); } } finally { if (bis != null) try { bis.close(); } catch (IOException ioe) { ioe.printStackTrace(); } if (bos != null) try { bos.close(); } catch (IOException ioe) { ioe.printStackTrace(); } } } else { log( "Input not available." ); } } </code></pre> <p>For more details I am using java.net imports.</p> <p>I am getting error : </p> <pre><code>Exception e is :: java.io.IOException: illegal filename for a PUT at sun.net.www.protocol.ftp.FtpURLConnection.getOutputStream(Unknown Source) at ToolFileUpload.upload(ToolFileUpload.java:72) at APInterfaceTool.uploadFile(APInterfaceTool.java:861) at APInterfaceTool.createInvoiceTextFile(APInterfaceTool.java:613) at APInterfaceTool.generateOutBoundExtract(APInterfaceTool.java:426) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload