Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (578)
games submitted by our members
Games in WIP (499)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  signed applets weirdness  (Read 1233 times)
0 Members and 1 Guest are viewing this topic.
Offline alexxz4

Junior Member


Projects: 1



« Posted 2007-06-24 21:05:09 »

ok, so i signed my applet, and it has this code in it:

1  
2  
3  
4  
5  
6  
7  
try{
         DataOutputStream file=new DataOutputStream(new BufferedOutputStream(
            new FileOutputStream(new File("file.txt"))));
         file.writeBytes("hello file");
         file.flush();
         file.close();
} catch(IOException exp){}


which is supposed to test how well i signed the jar. It does not show any exceptions but the file is not written.
Is the file supposed to be written inside the JAR or in its derictory. I checked every part of my JAR and the file isnt there.   Huh

[ Motherload Unlimited looking for programmers ] [ Solitaire ]
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #1 - Posted 2007-06-24 21:55:56 »

The jar itself (once it's in the cp) is read only. With a path like that it's written into the current working directory... whatever that might be. Just search for that file and you might find it.

Btw the minimum catch block contains a printStackTrace(). Otherwise you won't get a hint what went wrong (that is if something went wrong).

弾幕 ☆ @mahonnaiseblog
Offline alexxz4

Junior Member


Projects: 1



« Reply #2 - Posted 2007-06-24 22:36:36 »

the file is actually written to the desktop   Shocked, even though my working directory is 6 levels below it.
So there is no way to write the file to the derictory and then read it when i need to?

U dont have to put anything between the catch block braces. I tried that before i signed my applet and it threw exceptions as expected.

[ Motherload Unlimited looking for programmers ] [ Solitaire ]
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #3 - Posted 2007-06-25 01:14:54 »

>So there is no way to write the file to the derictory and then read it when i need to?

If you use the same path for reading, it works fine. Well, just create a subdir in the user dir ("user.dir" system property) with a leading dot (eg ".foo").

>U dont have to put anything between the catch block braces.

I know. I meant the minimum one should put there.

弾幕 ☆ @mahonnaiseblog
Offline alexxz4

Junior Member


Projects: 1



« Reply #4 - Posted 2007-06-25 17:23:07 »

Quote
If you use the same path for reading, it works fine. Well, just create a subdir in the user dir ("user.dir" system property) with a leading dot (eg ".foo").
the problem is that when "file.txt" is read, it reads it from inside the jar and when i write it, its written on the desktop.

Another question (not related, but dont wanna start a new thread).

Suppose i have an array of bytes 60x1000. And depending on what the value is i wanna draw a sprite at certain position.
1  
2  
3  
4  
5  
6  
7  
8  
9  
for(int i=0;i<20;i++)
for(int j=0;j<10;j++){
int x1=i*50,y1=j*50;
if(arr[i][j]==0)g.drawImage(img0,x1,y1,null,this);
else if(arr[i][j]==1)g.drawImage(img1,x1,y1,null,this);
else if(arr[i][j]==2)g.drawImage(img2,x1,y1,null,this);
...
else if(arr[i][j]==30)g.drawImage(img30,x1,y1,null,this);
}

I was wondering since the cell value corresponds to the image name, can i do something like this
1  
2  
3  
4  
5  
for(int i=0;i<20;i++)
for(int j=0;j<10;j++){
int x1=i*50,y1=j*50;
g.drawImage("img"+toString(arr[i][j]),x1,y1,null,this);
}


not sure if that'll work, but u get the idea

[ Motherload Unlimited looking for programmers ] [ Solitaire ]
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #5 - Posted 2007-06-25 17:31:25 »

>the problem is that when "file.txt" is read, it reads it from inside the jar and when i write it, its written on the desktop.

Use a complete path to read/write the configuration.

@The other question

Well, use arrays.

g.drawImage(tiles[map[x][y]],...); (tiles contains the tile images, and the 2d map array contains the indices)

弾幕 ☆ @mahonnaiseblog
Offline alexxz4

Junior Member


Projects: 1



« Reply #6 - Posted 2007-07-10 19:03:58 »

1  
g.drawImage(tiles[map[x][y]],...);

of course, me stupid . . .   Grin

Few more questions.
1. How can u determine at what speed an applet runs? CPU does not show it (my game runs at 4% CPU max, but on a slower computer it runs at 100% and really really slow).
2. How much memory can Java handle and does it influence game speed? How many images or arrays? ( a rough estimate)
3. How can I draw a bunch of stuff to an empty image and then draw the image on the screen. (Would it like kill the cpu or memory?)

Thanckxs   Grin

[ Motherload Unlimited looking for programmers ] [ Solitaire ]
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (27 views)
2014-04-15 18:08:23

BurntPizza (24 views)
2014-04-15 03:46:01

UprightPath (38 views)
2014-04-14 17:39:50

UprightPath (21 views)
2014-04-14 17:35:47

Porlus (36 views)
2014-04-14 15:48:38

tom_mai78101 (61 views)
2014-04-10 04:04:31

BurntPizza (119 views)
2014-04-08 23:06:04

tom_mai78101 (219 views)
2014-04-05 13:34:39

trollwarrior1 (186 views)
2014-04-04 12:06:45

CJLetsGame (193 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!