Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in Java only
Search
Advanced Search
Forums
Product Launch
Updates
Today's Posts
Member List
Calendar
Home
Forum
Topic
Java
how to upload multiple files using java
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
subaganesan
New Member
Join Date:
Mar 2008
Posts:
1
#1
how to upload multiple files using java
Mar 3 '08, 05:44 AM
hello
i am in need to upload multiple files. help me.......
gaya3
New Member
Join Date:
Aug 2007
Posts:
184
#2
Mar 3 '08, 06:10 AM
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
Post
Cancel
r035198x
MVP
Join Date:
Sep 2006
Posts:
13225
#3
Mar 3 '08, 09:33 AM
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
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment