 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Sam Guest
|
Posted: Fri Aug 22, 2003 9:17 pm Post subject: FileOutputStream in an applet |
|
|
Here's my problem, i'm trying to write a file on the hard disk
it's working fine when i execute the applet from JBuilder, the file is
writen on the disk in the base directory of my project and everythings are
fine.
when im executing the html page from jbuilder it save to jbuilder/bin and
its still fine
but the problem is when im loading the html containing the applet from IE
the file is not created and no messagedialog popup
here's my code :
String filename = "nameofthefile.txt";
try{
FileOutputStream f = new FileOutputStream(filename);
...
// File writing stuff
...
if(f.getChannel().isOpen()){
JOptionPane.showMessageDialog(null, null, "Valid",
JOptionPane.INFORMATION_MESSAGE);
}else{
JOptionPane.showMessageDialog(null, null, "Not Valid",
JOptionPane.ERROR_MESSAGE);
}
f.close();
}
catch (IOException e) {
JOptionPane.showMessageDialog(null,null,
e.getMessage(),JOptionPane.ERROR_MESSAGE);
System.out.println(e.getMessage());
}
thanks for your help
|
|
| Back to top |
|
 |
pnichols Guest
|
Posted: Sat Aug 23, 2003 1:55 am Post subject: Re: FileOutputStream in an applet |
|
|
Sam wrote:
| Quote: | Here's my problem, i'm trying to write a file on the hard disk
it's working fine when i execute the applet from JBuilder, the file is
writen on the disk in the base directory of my project and everythings are
fine.
when im executing the html page from jbuilder it save to jbuilder/bin and
its still fine
but the problem is when im loading the html containing the applet from IE
the file is not created and no messagedialog popup
You will have to write a security descriptor to code sign the applet. This |
can done using a commercial offering like Verisign or you can use the
GenKey too in the Java 2 SDK.
Search from Google for a response to Applet Database Access some time back
to find the example I gave on how to do this in this NG.
|
|
| Back to top |
|
 |
Sam Guest
|
Posted: Mon Aug 25, 2003 3:35 pm Post subject: Re: FileOutputStream in an applet |
|
|
| Quote: | You will have to write a security descriptor to code sign the applet. This
can done using a commercial offering like Verisign or you can use the
GenKey too in the Java 2 SDK.
|
Thx, but i want to write files to the server, not the client. Any way i can
do that ?
i've read some docs on that, but i dont understand the output classes and
the writebyte system to work on server side.
thx for the help
Sam
|
|
| Back to top |
|
 |
Rich Wilkman Guest
|
Posted: Wed Aug 27, 2003 1:43 am Post subject: Re: FileOutputStream in an applet |
|
|
Sam:
Your applet would send data to a server side widget (usually a servlet)
and the servlet would do the writing on the server as a normal Java program.
-Rich
Sam wrote:
| Quote: | You will have to write a security descriptor to code sign the applet. This
can done using a commercial offering like Verisign or you can use the
GenKey too in the Java 2 SDK.
Thx, but i want to write files to the server, not the client. Any way i can
do that ?
i've read some docs on that, but i dont understand the output classes and
the writebyte system to work on server side.
thx for the help
Sam
|
|
|
| Back to top |
|
 |
Sam Guest
|
Posted: Wed Aug 27, 2003 8:02 pm Post subject: Re: FileOutputStream in an applet |
|
|
Ok thank you Rich, i've made that i'm now able to create a file on the
server using a servlet.
Now the question is : i'm sending a string containing line feed and cariage
return (the data is a png image) everythings fine until it get into the
servlet. the created file is missing every line feed and cariage return
caracters.
here's my code:
File f = new File("C:/path/to/file/picture.png");
FileOutputStream fos = new FileOutputStream(f);
DataOutputStream dos = new DataOutputStream(fos);
BufferedReader in = request.getReader();
String strChar;
while ((strChar = in.readLine())!= null){
dos.writeBytes(strChar);
}
i've tried writing char by char but i've got problem
char[] cChar={};
int nbChar = in.read(cChar);
nbChar is always 0.
if i could write exactly what is in the bufferedreader it would resolve my
problem but it keep skiping lf and cr.
Any idea on how to read from the buffer and then write in the file as it
really is?
Thx for your help !
"Rich Wilkman" <richw (AT) formlessvoid (DOT) com> wrote
| Quote: | Sam:
Your applet would send data to a server side widget (usually a servlet)
and the servlet would do the writing on the server as a normal Java
program.
-Rich
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|