Article View: es.comp.lenguajes.java
Article #29640Desesperado: securityException
From: Jose M.
Date: Tue, 18 Nov 1997 00:00
Date: Tue, 18 Nov 1997 00:00
108 lines
3039 bytes
3039 bytes
Soy nuevo en esto del Java y ahora estoy haciendo algunos applets sencill=
os.
Hoy me he puesto a hacer uno que simplemente lea de un fichero de texto y=
lo
muestre en la pantalla. Pero no funciona porque me responde con excepcion=
es
de Seguridad. =
S=ED, ya s=E9 que los applets no pueden leer m=E1s all=E1 del sistema don=
de residen.
Por tanto si coloco el applet y el fichero de texto en el servidor web,
deber=EDa funcionar bien. Y si los coloco en el mismo directorio de mi di=
sco
duro, tambi=E9n. (de hecho tengo applets hechos por otra gente que s=ED f=
uncionan
bien). Pero el m=EDo no funciona, ni en mi disco local ni en el servidor.=
:-(
=BFCu=E1l es mi fallo???
Ah=ED van mis c=F3digos fuente. EL class, el html y el txt est=E1n en el =
mismo
directorio.
****************************html*************************
<html>
<head></head>
<body>
Probando applet...fich1<br>
<applet code=3D"fich1.class" width=3D"300" height=3D"150">
</applet>
</body>
</html>
******************************java**************************
import java.io.*;
import java.awt.*;
import java.applet.*;
public class fich1 extends Applet
{
public TextArea tarea;
public Button boton;
RandomAccessFile entrada;
String texto;
public void init() =
{
tarea=3Dnew TextArea(3,30);
boton=3Dnew Button ("L=E9elo!");
=
add(tarea);
add(boton);
}
=
public boolean action(Event e, Object cual)
{
if (e.target=3D=3Dboton)
{
=
try{
=
entrada=3Dnew RandomAccessFile(getCodeBase()+"texto.txt","r");
while (entrada.getFilePointer() < entrada.length())
{
tarea.setText(tarea.getText()+entrada.readChar());
}
}catch(Exception ex){tarea.setText(tarea.getText()+" Fallo "+ex);}
return true;
}
else
return false; =
}
}
***************************************************************
Fenkiu! :-)
-- =
______________________________________________________
Jose M. Julia' (Seldon on IRC) -- Madrid (Spain)
e-mail: jmjulia@arrakis.es
www: http://www.arrakis.es/~jmjulia
______________________________________________________
"Violence is the last refuge of the incompetent"
("La violencia es el ultimo recurso del incompetente")
Isaac Asimov
_____________________________________________________
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 2.6.2
mQBNAzRnpyIAAAECANNyhNwGufhhttAaSt5n69ZXInIde1Mw+U0yziSNhzt5uU2M
eqzFwuEkNHliCGNKzkW+tfwOYJMpcjeAXU7qaQEABRG0J0pvc2UgTWlndWVsIEp1
bGlhJyBQaW5vIChNYWRyaWQsIFNwYWluKQ=3D=3D
=3Dymt9
-----END PGP PUBLIC KEY BLOCK-----
Technical Details
Message-ID:
<34719726.9CAEAD79@arrakis.es>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII-7-bit X-Google-Thread: 1116f3,f685d09fed43a53d,start X-Google-Attributes: gid1116f3,public From: "Jose M." <jmjulia@arrakis.es> Subject: Desesperado: securityException Date: 1997/11/18 Message-ID: <34719726.9CAEAD79@arrakis.es> X-Deja-AN: 290445784 Organization: United Federation of Planets Newsgroups: es.comp.lenguajes.java