Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Discussions / General Discussions / can not write streams to file ? on: 2005-03-23 07:58:58
howdy~

i did some exercises on file I/O, but weird that i can only read but not write. here is my code below:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
import java.io.*;


class TestFile_001
{
      public static void main(String[] args) throws Exception
      {
            copy();
      }

      public static void copy() throws IOException
      {
            File fIn = new File("TestFileStreamRead.txt");
            File fOut = new File("TestFileStreamWrite.txt");

            FileReader fr = new FileReader(fIn);
            FileWriter fw = new FileWriter(fOut);

            int n;
            while(true)
            {
                  n = fr.read();
                  if (n != -1)
                  {
                        fw.write(n);
                  }
                  else
                  {
                        break;
                  }
            }
      }
}

TestFileStreamWrite.txt is always empty after running the code, which is supposed to have same content as TestFileStreamRead.txt, i'm sticked here. any solution pls ?
2  Discussions / General Discussions / possible to rotate an image ? on: 2005-02-23 00:13:26
hi all~

i wonder is there any way we can rotate an image say, 90 degrees orso ?
3  Discussions / General Discussions / sound volume control help ! on: 2005-02-18 00:59:07
hi all~

i'm developing a J2ME game based on MotoE680, my boos just requires in the game the user can control volume of bg sounds,  i found an interface "VolumeControl" can help but dunno how to derive its getLevel and setLevel to increase or decrease volume. here is the code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
public SoundControl implements VolumeControl
{
    ...

    public int getLevel()
    {
        // How to derive getLevel method here ???
   }
}

any help  ?
4  Discussions / General Discussions / Re: inner class problem~ on: 2005-02-04 00:23:26
tks guys and i already find another different solution, just remove main method in TestThread class and put initialization code inside it's constructor, then create another class named say, Test, and build instance of TestThread within Test's main method, it really works, ha!

to gamehacer2000: make it static seems a wonderful trick, i'd like to try it out, and this is the first time i got inner class can be implemented static :p
5  Discussions / General Discussions / Re: inner class problem~ on: 2005-02-03 07:38:59
Quote
All inner (private) classes require an outer (public) class when created because they have an implicit 'this' pointer to the outer object. So you can only really create instances of inner classes from an object of the outer class.

Ditch MyThread and move all its methods into TestThread, then just create an instance of that in main().


u mean to put inner class within the constructor ? i tried but it does not work yet, compiler just reports this:

---------- Java compiler ----------
TestThread1.java:7: illegal start of expression
           private class MyThread extends Thread
               ^
TestThread1.java:7: ';' expected
           private class MyThread extends Thread
                       ^
2 errors
Output completed (1 sec consumed) - Normal Termination

what's the problem here ?
6  Discussions / General Discussions / Re: inner class problem~ on: 2005-02-03 05:00:19
and here is the output looks like:

TestThread.java:7: non-static variable this cannot be referenced from a static context
           MyThread thread1 = new MyThread("black", 5);
                                  ^
TestThread.java:8: non-static variable this cannot be referenced from a static context
           MyThread thread2 = new MyThread("white", 3);
                                  ^
2 errors
Output completed (0 sec consumed) - Normal Termination

anyone could figure it out... tks !
7  Discussions / General Discussions / inner class problem~ on: 2005-02-03 04:57:49
my test code can not work properly, the matter is compiler forbid me from creating instances of the inner class within main method, how to fix it pls ?
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
public class TestThread
{
      public static void main(String[] args)
      {
            MyThread thread1 = new MyThread("black", 5);
            MyThread thread2 = new MyThread("white", 3);
            thread1.start();
            thread2.start();
      }

      private class MyThread extends Thread
      {
            public MyThread(String name, int num)
            {
                  this.name = name;
                  this.num = num;
            }

            public void run()
            {
                  for (int i=0; i<num; i++)
                  {
                        try
                        {
                              sleep((long)100);
                        }
                        catch (Exception e) {};
                        System.out.println(name + "\trunning: " + i);
                  }
            }

            private String name;
            private int num;
            public int xxx = 5;
      }
}


regards~
8  Discussions / General Discussions / Re: how to stop a thread safety ? on: 2005-02-03 03:50:37
tks, and another problem comes, myThread.sleep is handy to pause the running thread, however what if we do not know exactly time thread sleeping ? although passing a very big number to myThread.sleep is helpful i still prefer the way to stop current thread simply(better if we could run it from the point it stops), any suggestions ?

thanx in adv~
9  Discussions / General Discussions / how to stop a thread safety ? on: 2005-02-03 01:40:34
hi all~

i start running a thread by calling myThread.start method but there seems no something like myThread.stop() or myThread.die to stop it eternally, of course i could do this by setting the thread to null(like the code below):
1  
myThread = null;

and is this the only way we could stop the running thread ?

regards~
10  Discussions / General Discussions / Re: what neccesary when developing a game with Jav on: 2005-02-02 05:39:58
tks, after all it is swing, ha, did it the one choosen by most people ?
11  Discussions / General Discussions / what neccesary when developing a game with Java ? on: 2005-02-02 01:08:10
howdy~

im experienced on programming games with J2ME, but it is not such independant and i wonder are there any other ways to developing games with Java, i know awt and swing may help, but it seems those two are not enough and making games are not really their goals, any one could tell me about what tools and packages used for games ?

regards~
12  Java Game APIs & Engines / J2ME / Re: how can we abtain sin and cos methods ? on: 2005-02-02 00:32:39
if im with cldc1.1 then how could i achieve exactly sin, cos and tag values ?

regards~
13  Java Game APIs & Engines / J2ME / sound problem on: 2005-01-26 00:43:43
howdy~

i created some midi streams into the game and so when the time i wanted i stopped and play from its head again, i tried player.stop(javax.microedition.media.Player class) method but it only get sounds paused and when i played that sound again by player.start it would go on from the place get paused, i hated this way and want it play from the beginning, any suggestions ?

tks~
14  Java Game APIs & Engines / J2ME / how can we abtain sin and cos methods ? on: 2005-01-26 00:24:27
howdy~

i'm developing a game based on J2ME which needs sin, cos and tag values but i found no such methods in J2ME, is there any way to do that then ?
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

pw (22 views)
2014-07-24 01:59:36

Riven (20 views)
2014-07-23 21:16:32

Riven (17 views)
2014-07-23 21:07:15

Riven (20 views)
2014-07-23 20:56:16

ctomni231 (48 views)
2014-07-18 06:55:21

Zero Volt (44 views)
2014-07-17 23:47:54

danieldean (35 views)
2014-07-17 23:41:23

MustardPeter (38 views)
2014-07-16 23:30:00

Cero (53 views)
2014-07-16 00:42:17

Riven (52 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!