how to upload multiple files using java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • subaganesan
    New Member
    • Mar 2008
    • 1

    how to upload multiple files using java

    hello

    i am in need to upload multiple files. help me.......
  • gaya3
    New Member
    • Aug 2007
    • 184

    #2
    Originally posted by subaganesan
    hello

    i am in need to upload multiple files. help me.......

    Hi,
    For uploading multiple files.. u may use scanners..
    I have tried out one sample example wit that,it works fine..

    import java.io.*;
    import java.util.*;
    class MultipleFiles{
    public static void main(String args[]){
    System.out.prin tln("Enter the number of files to upload::::::::: :");
    Scanner sc = new Scanner(System. in);
    int i = sc.nextInt();
    System.out.prin tln("Enter the file names to upload::::::::: :");
    try{
    for(int j=0;j<i;j++) {
    String fileName = (String)sc.next ();
    File file = new File(fileName);
    FileReader reader = new FileReader(file );
    BufferedReader buff = new BufferedReader( reader);
    String str = null;
    StringBuffer strBuff = new StringBuffer();
    while( (str=buff.readL ine()) != null){
    strBuff.append( str);
    }
    System.out.prin tln("Uploaded File contents::::::: :::::::: : "+strBuff);
    }}
    catch(Exception e){
    e.printStackTra ce();
    }}}

    Am i undersatnding ur query in rt way?

    -Thanks
    Hamsa

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by gaya3
      Hi,
      For uploading multiple files.. u may use scanners..
      I have tried out one sample example wit that,it works fine..

      import java.io.*;
      import java.util.*;
      class MultipleFiles{
      public static void main(String args[]){
      System.out.prin tln("Enter the number of files to upload::::::::: :");
      Scanner sc = new Scanner(System. in);
      int i = sc.nextInt();
      System.out.prin tln("Enter the file names to upload::::::::: :");
      try{
      for(int j=0;j<i;j++) {
      String fileName = (String)sc.next ();
      File file = new File(fileName);
      FileReader reader = new FileReader(file );
      BufferedReader buff = new BufferedReader( reader);
      String str = null;
      StringBuffer strBuff = new StringBuffer();
      while( (str=buff.readL ine()) != null){
      strBuff.append( str);
      }
      System.out.prin tln("Uploaded File contents::::::: :::::::: : "+strBuff);
      }}
      catch(Exception e){
      e.printStackTra ce();
      }}}

      Am i undersatnding ur query in rt way?

      -Thanks
      Hamsa
      1.) Use code tags when posting code
      @OP Upload from where to where?

      Comment

      Working...