No subject
Sat Nov 12 19:29:10 PST 2005
server to get the length of that file which is stopped
in between.After that I want to skip() that portion in
InputStraem read().In my servlet I want to put
condition basis output stream that means if it is new
file then:-
In my servlet:-
===============
// create a DataInputStream to read from sender
DataInputStream dis;
dis = new DataInputStream(request.getInputStream());
OutputStream os;
// create file output stream to write the output file
System.err.println("Using output file " + outfile);
os = new BufferedOutputStream(new
FileOutputStream(outfile));
And if it is Resume file server should open that file
in append mode instead of writting in the file:-
====================================================================================================
DataInputStream dis;
dis = new DataInputStream(request.getInputStream());
OutputStream os;
// create file output stream to write the output file
System.err.println("Using output file " + outfile);
os = new BufferedOutputStream(new
FileOutputStream(outfile,true));
the servlet would have to be able to distinguish these
two cases for that I want to use "if,else" condition
but what will be the condition. Iam using for new file
[FileOutputStream(File fileobj)] constructor.And for
append I should use [FileOuputStream(String
filepath,boolean append)] constructor.
But Iam confused how I can use
[FileOutputStream(String filepath)] constructor in
case of new file.
servlet file:-
============
...............
..............
String filename;
filename = request.getParameter("name");
String path;
path = request.getParameter("path");
File outfile = new File(filename);
outfile = new File(path, filename);
....................
.....................
Interface:-(Resume portion code)
=========
..............
..............
//create url
u1 = new URL(base + "?name="
+URLEncoder.encode(f.getName()) + "&path="
+URLEncoder.encode(path));
..........
try {
// step 7 - open the input stream
log("step 7 - open the input stream");
InputStream is = uc.getInputStream();
//skip the bytes already have in server
is.skip(str);
// step 8 - read the input stream
int cc;
byte [] buf = new byte[512];
log("step 8 - read the input stream");
for(cc = is.read(buf, 0, 512); cc > 0; cc =
is.read(buf, 0, 512)) {
log(new String(buf, 0, cc));
}
// step 9 - close the input stream
log("step 9 - close the input stream");
is.close();
.............
.............
Regards
Bikash
__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/
More information about the Advanced-java
mailing list