Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FilePermissionExeption.... fuc#¤%&%!%¤

0 views
Skip to first unread message

Knut Chr. Brinch

unread,
Oct 16, 2000, 3:00:00 AM10/16/00
to
This - I`m shure is a stupid mistake but when Debugged step by step
everything works fine!
But when "run" I get the FilePermissionExeption. I am completly stuck with
this code!
¤#%&!¤/#%/&)¤&/()................

Thanks a million!

Knut

import java.io.*;
import java.lang.String;
import javax.swing.*;
import java.security.*;

public class JavaTema extends JApplet {

static String text1;
static String path;
static String permissionS;
File fil;
FilePermission perm;

public JavaTema() {
path = new String("ALL FILES");
permissionS = new String("read");
perm = new FilePermission(path, permissionS);
text1 = new String(Innhold());
fil = new File("C:/CHANGES.txt");
initComponents ();
}

public String Innhold() {
String s = new String();
char[] buff = new char[500000];
InputStream is;
InputStreamReader reader;
perm.checkGuard(perm);

try {

is = new FileInputStream(fil);
reader = new InputStreamReader(is);
int nch;
while ((nch = reader.read(buff, 0, buff.length)) != -1) {
s = s + new String(buff, 0, nch);
}
} catch (IOException ex) {
showStatus("This didnt work");
}

return s;
}//Innhold

private void initComponents () {//GEN-BEGIN:initComponents
Tabulator = new javax.swing.JTabbedPane ();
IntroScroll = new javax.swing.JScrollPane ();
Intro = new javax.swing.JTextArea ();

Tabulator.setTabPlacement (4);


Intro.setEditable (false);
Intro.setText (text1);

IntroScroll.setViewportView (Intro);

Tabulator.addTab ("Introduction", IntroScroll);


getContentPane ().add (Tabulator, java.awt.BorderLayout.CENTER);

}//GEN-END:initComponents


// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTabbedPane Tabulator;
private javax.swing.JScrollPane IntroScroll;
private javax.swing.JTextArea Intro;
// End of variables declaration//GEN-END:variables

}

Anthony Shipley

unread,
Oct 16, 2000, 3:00:00 AM10/16/00
to
"Knut Chr. Brinch" <k-br...@frisurf.no> wrote:

>¤#%&!¤/#%/&)¤&/()................
Sorry, I can't help, but may I use the above?

:-)

anthony shipley

<math> 2 + 2 = 5 for sufficiently large values of 2</math>

Knut Chr. Brinch

unread,
Oct 16, 2000, 3:00:00 AM10/16/00
to
If its the code you are reffering to.......
Yes go ahead and help yourself

But it wont work ofcourse

knut

"Anthony Shipley" <ast...@iinet.net.au> wrote in message
news:g3jlus0nm5d99qhig...@4ax.com...

Anthony Shipley

unread,
Oct 16, 2000, 3:00:00 AM10/16/00
to
"Knut Chr. Brinch" <k-br...@frisurf.no> wrote:

>If its the code you are reffering to.......
>Yes go ahead and help yourself

No, it was the ¤#%&!¤/#%/&)¤&/()................
So expressive :-)

Ivo Limmen

unread,
Oct 16, 2000, 3:00:00 AM10/16/00
to

"Knut Chr. Brinch" <k-br...@frisurf.no> wrote in message
news:uZxG5.7272$W31.1...@news1.online.no...

-----8<-----------------8<--------------------


> fil = new File("C:/CHANGES.txt");

-----8<-----------------8<--------------------
Should be:
fil = new File("C:\\CHANGES.txt");

but remember that it is only works on Widows, if you would want to use the
program on other platforms and program 100% pure then you should check
os.arch en the other properties to determine the path delimiters...

Ivo

Knut Chr. Brinch

unread,
Oct 16, 2000, 3:00:00 AM10/16/00
to
Thanks alot!!

What a stupid mistake!
I suspected it was somthing about the dir.
Did try to use url: file://c:/CHANGES.txt too, but that didnt work either,
probably wrong that too.

Well....... wont do that again!

Knut

"Ivo Limmen" <lim...@furore.nl> wrote in message
news:8setri$o9g$1...@porthos.nl.uu.net...

Knut Chr. Brinch

unread,
Oct 16, 2000, 3:00:00 AM10/16/00
to
Well thanks!
And I got your attention :-)

knut


"Anthony Shipley" <ast...@iinet.net.au> wrote in message

news:qcplusc0q6q2v73vc...@4ax.com...

Knut Chr. Brinch

unread,
Oct 16, 2000, 3:00:00 AM10/16/00
to
Still dont work!!!!!!

I assumed it was the dir. But that didnt fix anything!

Still that fuc£${$?%¤&/((/&

java.security.AccessControlException: access denied
(java.io.FilePermission ALL FILES read)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java
:272)
at
java.security.AccessController.checkPermission(AccessController.java:399)
at
java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
at java.security.Permission.checkGuard(Permission.java:86)
at JavaTema.Innhold(JavaTema.java:38)
at JavaTema.<init>(JavaTema.java:28)
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Class.java:237)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:579)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:515)
at sun.applet.AppletPanel.run(AppletPanel.java:293)
at java.lang.Thread.run(Thread.java:484)

Jon Davis

unread,
Oct 16, 2000, 3:00:00 AM10/16/00
to
The file is apparently locked by either another File object or by another
Windoze process.

Jon


"Knut Chr. Brinch" <k-br...@frisurf.no> wrote in message

news:dDGG5.7725$W31.1...@news1.online.no...

Knut Chr. Brinch

unread,
Oct 17, 2000, 3:51:08 AM10/17/00
to
Well I have tried a lot of different files thinking about that possibility,
but it wont work.
Its a strange thing, because my code seems ok!!

knut


"Jon Davis" <jon....@REMOVE.ME.ebalance.com> wrote in message
news:sun0hva...@news.supernews.com...

Ivo Limmen

unread,
Oct 17, 2000, 3:00:00 AM10/17/00
to
I tried to run your program but I can't get it to work... I don't get the
same error as you do.
I can't run it in a browser and stand-alone because it has no main...
How did you intended to use it?

I made a console java app to test how to open a file:

---------------------
import java.io.*;

public class Test {
private String str;

public static void main(String[] args) {
Test t = new Test();

t.test();

t = null;
}

public void test() {
try {
FileInputStream in;

str = new String();
// completely read the template
in = new FileInputStream("C:\\CHANGES.txt");
while(in.available() > 0) {
str+=(char)in.read();
}

System.out.println(str);
in.close();
in = null;
}
catch(Exception e) { }
}
}
---------------------

<<This works....>>

Ivo

Jon Davis

unread,
Oct 17, 2000, 3:00:00 AM10/17/00
to
Reboot.

Jon


"Knut Chr. Brinch" <k-br...@frisurf.no> wrote in message

news:HISG5.8160$W31.1...@news1.online.no...

Knut Chr. Brinch

unread,
Oct 17, 2000, 3:00:00 AM10/17/00
to
Normally it will work without a main, but I have in some cases gotten the
same error as you!
Then I just insert an empty main class.
The use of this is only for applet-usage, and for reading text in an mutiple
togglebutton class!
Thats why it normally can run without a main because it only initializes
visual components!

knut


"Ivo Limmen" <lim...@furore.nl> wrote in message

news:8sh00m$o8l$1...@porthos.nl.uu.net...

Hydra

unread,
Oct 17, 2000, 5:43:12 AM10/17/00
to
In article <8setri$o9g$1...@porthos.nl.uu.net>, lim...@furore.nl says...

> Should be:
> fil = new File("C:\\CHANGES.txt");

Forward slahes work just fine on windows, the File class will translate
them for you.

Niels
--
Mail: hydra1m...@wxs.ONIONnl (Eat your veggies)
Page: http://home.conceptsfa.nl/~hydra/
"One Ring to rule them all, One Ring to find them,
One Ring to bring Them all and in the darkness bind them
In the Land of Mordor where the Shadows lie."

Joni Niemi

unread,
Oct 18, 2000, 3:00:00 AM10/18/00
to
"Knut Chr. Brinch" wrote:

> ¤#%&!¤/#%/&)¤&/()................
..


> path = new String("ALL FILES");

The API says: 'The special pathname "<<ALL FILES>>" matches all
files.' Isn't there something missing in your String?

Joni
--
Joni Niemi | All marriages are happy. It's living
Joni....@iki.fi | together afterwards that is difficult.
http://www.iki.fi/joni/ | -- Anonymous

0 new messages