fork(1) download
  1. import java.io.File;
  2. import java.io.FileInputStream;
  3. import java.io.FileOutputStream;
  4. import java.io.InputStream;
  5. import java.io.InputStreamReader;
  6.  
  7.  
  8. import org.apache.commons.io.IOUtils;
  9. import org.apache.myfaces.trinidad.model.UploadedFile;
  10.  
  11. import com.ibm.ws.webservices.xml.wassysapp.systemApp;
  12.  
  13.  
  14. public class TestFile {
  15.  
  16. public static void main(String args[]){
  17.  
  18. TestFile tf = new TestFile();
  19. tf.onUpload();
  20. }
  21.  
  22.  
  23.  
  24. public String onUpload() {
  25. UploadedFile myAttachment = null;//getFile();
  26. FacesMessage message = null;
  27.  
  28. FileOutputStream newFile = null;
  29. try {
  30. File f = new File("C:\\RPC\\config\\RpcJdbc.log");
  31. System.out.println(">> Attachment: " + f.getName());
  32. String strWriteFilePath = "c:\\Temp\\" + f.getName();
  33. newFile = new FileOutputStream(strWriteFilePath);
  34. InputStream streamIn = new FileInputStream(f);
  35.  
  36. System.out.println("<copy>: " + IOUtils.copy(streamIn, newFile));
  37. System.out.println("Successfully uploaded attachment ");
  38. // message = new FacesMessage("Successfully uploaded attachment " + newFile.getFilename());
  39. } catch (Exception e) {
  40. e.printStackTrace();
  41. //message = new FacesMessage("Invalid Attachment, try again!");
  42. } finally {
  43. IOUtils.closeQuietly(newFile);
  44. }
  45. return null;
  46. }
  47.  
  48.  
  49. }
  50.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:14: class TestFile is public, should be declared in a file named TestFile.java
public class TestFile {
       ^
Main.java:8: package org.apache.commons.io does not exist
import org.apache.commons.io.IOUtils;
                            ^
Main.java:9: package org.apache.myfaces.trinidad.model does not exist
import org.apache.myfaces.trinidad.model.UploadedFile;
                                        ^
Main.java:11: package com.ibm.ws.webservices.xml.wassysapp does not exist
import com.ibm.ws.webservices.xml.wassysapp.systemApp;
                                           ^
Main.java:25: cannot find symbol
symbol  : class UploadedFile
location: class TestFile
        UploadedFile myAttachment = null;//getFile();
        ^
Main.java:26: cannot find symbol
symbol  : class FacesMessage
location: class TestFile
            FacesMessage message = null;
            ^
Main.java:36: cannot find symbol
symbol  : variable IOUtils
location: class TestFile
            System.out.println("<copy>: " + IOUtils.copy(streamIn, newFile));
                                            ^
Main.java:43: cannot find symbol
symbol  : variable IOUtils
location: class TestFile
            IOUtils.closeQuietly(newFile);
            ^
8 errors
stdout
Standard output is empty