Problem with byte array

i wrote the following code:
public class Test {
byte [] ba = new byte[10];
void print(String s) { System.out.println(s); }
void printInitialValues() {
for (int i=0; i<10; i++)
ba[i] = (byte)0;
//System.arraycopy("asdf".getBytes(), 0, ba, 0, 4);*/
print("byte array " + ba);
public static void main(String[] args) {
Test iv = new Test();
iv.printInitialValues();
why the output isn't the string of serial '0', instead, it seems the random output.
when i put the line "System...." to the code, the result is the same.
Anybody can tell me why?
Regards,
Jason

Continued [url http://forum.java.sun.com/thread.jsp?forum=31&thread=551032&tstart=0&trange=15]here.

Similar Messages

  • Problem with byte array arguments in webservice method call

    I am using JWSDP 1.5 to generate client stubs for a webservice hosted on a Windows 2000 platform.
    One of the methods of the webservice contains a byte array argument. When our application calls this method passing the contents of a TIFF file as the byte array, the method is failing. I have discovered that tthe reason for the failure is that the byte array in the SOAP message has been truncated and is missing its terminating tag.
    Is this a known problem in JWSDP 1.5? Is there a fix for it? Does JWSDP 1.6 resolve this problem?
    Any assistance will be much appreciated.
    Regards,
    Leo

    I'd like to add the the webservice being invoked by the generated client stubs is rpc/encoded.

  • Repost: Problem with byte array

    i wrote the following code:
    public class Test {
    byte [] ba = new byte[10];
    void print(String s) { System.out.println(s); }
    void printInitialValues() {
    for (int i=0; i<10; i++)
    ba = (byte)0;
    //System.arraycopy("asdf".getBytes(), 0, ba, 0, 4);*/
    print("byte array " + ba);
    public static void main(String[] args) {
    Test iv = new Test();
    iv.printInitialValues();
    }why the output isn't the string of the serial '0', instead, it seems the random output.
    when i put the line "System...." to the code, the result is the same.
    Can anybody tell me why?
    Regards,
    Jason

    Your byte[] is an object of the type Array. Array does
    not override toString(), and thus you get the default
    Object.toString() behavior. If you want to print out
    the array elements, you'll need to iterate through the
    array manually.And in 1.5 you can use this:
    Arrays.toString(byteArray);/Kaj

  • Problem with an array (Array index out of bounds)

    Hey guys, i have a problem with an array, i just want to print a few things but it won't let me because of this error, here's my code
         public static void MosDat()
              int i;
              for(i=0 ; i<n ; i++);
                   Client [ i ].print1();
                   Client [ i ].print2();
              return;
         }//MosDat
    where "n" is a global variable, and client is .
    I pretty much know how it woks, so i tried it like this and gave "n" the value of "1":
    public static void MosDat()
              int i;
              for(i=0 ; i<n ; i++);
                   Client [ 0 ].print1();
                   Client [ 0 ].print2();
              return;
         }//MosDat
    the printing methods i created worked prefectly when i tried it like that... so i really don't know where the problem could be... thanks anyone who can help me.

    for(i=0 ; i < n ; i++);I spy with my little eye,
    one semicolon too many.Well-spotted. ;-)Practicing on those weird question marks is my secret training.

  • Performance Problems with intrinsic array multiplikation in Fortran with Su

    Hello,
    I found a serious performance problem in my application with intrinsic array multiplikation. Therefore I wrote a small test program to check if this a general problem or only exists in my code.
    The test program (as seen below) was compiled with Sunstudio12 und Solaris 5.10 on an 64 bit Amd Opteron Machine. First with high optimization (f95 -fast -g), and the second time with out optimization (f95 -O0 -g). In both cases the intrinsic array mupltiplication had a lot of tlb and L2 cache misses (I made some test with the performance analyzer) which caused a huge increase in computation time compared to the explicit loop. In the ideal case the compiler should create the nested loops from the intrinsic statement and both functions should use exactly the same computing time.
    I also tried compiling with Studio11, the problem also occurs there. Maybe its a compiler bug but I'm not sure.
    Greetings
    Michael Kroeger
    program test
    !Test zur Ausfuehrung einer einfachen array Multiplikation
    implicit none
    real,dimension(:,:,:),pointer::check1,check2
    integer i,j,k,ni,nj,nk,status
    ni=1000
    nj=1000
    nk=100
    allocate(check1(0:ni,0:nj,0:nk),STAT=status)
    write(*,*)status
    allocate(check2(0:ni,0:nj,0:nk),STAT=status)
    write(*,*)status
    check1(i,j,k)=25
    check2(i,j,k)=25
    call intrinsic_f(check1)
    call withloop(check2,i,j,k)
    deallocate(check1,check2)
    contains
    subroutine intrinsic_f(check1)
    real, dimension(:,:,:),pointer::check1
    check1=check1*5
    end subroutine intrinsic_f
    subroutine withloop(check2,ni,nj,nk)
    real, dimension(:,:,:),pointer::check2
    integer i,j,k,nk,nj,ni
    do k=0,nk
    do j=0,nj
    do i=0,ni
    check2(i,j,k)=check2(i,j,k)*5
    enddo
    enddo
    enddo
    end subroutine withloop
    end program

    I will try the large pages, but what me puzzles is, that the intrinsic function has cache misses, but the loop function has not. All documentation says, that the compiler would expand the intrinsic function into 3 nested loops, so that both functions should be essential the same (and the compiler says it has created 3 loops from the intrinsic). Since they are not the same, this is a severe problem.
    I have a fairly large code for high performance simulations, and this intrinsic functions are a significant bottle neck. If it is not a compiler bug, I would have to rewrite all intrinsic functions into loops.

  • Problem with cloning Array

    I got a problem with cloning a Point[] Array.
    for example i have 2 Point-Arrays declared as Membervariables:
    Point[] array1;
    Point[] array2;then in the constructor i filled array1 with random Point Objects
    and then
    array2 = (Point[])(array1.clone());then i, for example, add 5 to the x-coordinate of every Point in array2.
    for (int i = 0; i < array2.length; i++)
         array2.x += 5;
    But array1's Point objects are also changed when i do that!
    Shouldnt clone copy the whole array and leave no connection between them?
    Thanks in advance

    so i made a method copyArray where every point object's x and y value is copied into the new Array's new Point Object, but as it seems that isnt where the error comes from.
    (That method works fine, the arrays are identical after that, but shouldnt reference to the same chunk of memory, right?)
    then i run the following method on array2
    array2 = (Point[])addFive(array2);
    Point[] addFive(Point[] array)
                    array[0].x += 5;
              return line;
         }Hence array2[0].x is instead of, e.g., zero 5
    But array1[0] .x is 5 intead of 0 too!
    Where's the mistake, where's the reference left? =X (and how do i fix it? :))

  • Problem with building array inside a case statement

    I have a problem with my build array.
    Iam trying to construct a build array when ever I see a new element in my parent array during run time.
    Using shift registers, search array and If- case structure, inside a while loop. Iam implementing this logic (I dont want to use Event structure).
    Iam able to achieve most part of it, but have a problem with the first element. Except the first element of my parrent array, every thing is appending in to the build array. Can any one look at my vi and suggest me what Iam doing wrong here.
    Thank you
    Attachments:
    debug.vi ‏12 KB

    I think you need to replace the tunnels (carrying the array) in the for loop with a shift register.
    Lynn

  • Problems with an array (attachMovie)

    I've created a 20 x 20 grid of objects (openCircles). They're set to 'alpha = 0', then 'alpha = 100' on rollover. This works for all of them except for the final one at the coordinate T,20 in the bottom right corner, as I'm not able to rollover over it. To test whether or not they all existed, I set them all to an initial value of 'alpha = 100' and they did all appear, but I'm still unable to rollover the one at T20.
    The other problem is that when an 'openCircle' is clicked, a 'filledCircle' (set up as another grid of invisible objects in the same place) is supposed to appear in its place. That doesn't happen. All of the objects are created and exist, using attachMovie, so it's maybe due to some logical error. See code:-
    I'd be grateful for any help. Many thanks.
    stop();
    //The purpose of this experiment is to locate a trap of oil. Only 30 exploration holes are allowed.
    //Use the grid coordinate to locate the borehole and then plot the depth
    //Drilled is set to false in the 1st(previous) frame
    //Rolling over a grid coordinate will reveal a borehole (open circle).
    //Click on the borehole (open circle) to start drilling
              //open circle will be removed
              //drilled is set to true for that coordinate
              //filled circle will appear in its place
    //set up variables for grid array of open circles (undrilled) and closed circles (drilled)
    var spacing:Number = 5.75;
    var cols:Number = 20; // number of columns in grid
    var rows:Number = 20; // number of rows in grid
    var leftMargin:Number = 154;
    var topMargin:Number = 169;
    var currentRow:Number = 0;
    var currentCol:Number = 0;
    for (i=1; i<=rows; i++) {                                                                                                         
    for (j=1; j<=cols; j++) {                                                                                                                              
              current = attachMovie("openCircle_mc", "openCircle_mc"+i+"_"+j,getNextHighestDepth());
              current._x = leftMargin + ((i-1) * (spacing + current._width));
              current._y = topMargin + ((j-1) * (spacing + current._height));
              current2 = attachMovie("filledCircle_mc", "filledCircle_mc"+i+"_"+j, getNextHighestDepth());
              current2._x = leftMargin + ((i-1) * (spacing + current2._width));
              current2._y = topMargin + ((j-1) * (spacing + current2._height));
              //open circle initially invisible, then visible on rollOver
              current._alpha = 0;
              //filled circles initially invisible
              currentCol2=(current2._x-leftMargin)/(spacing + current2._width);
              currentRow2=(current2._y-topMargin)/(spacing + current2._height);
                                     if (drilled[currentCol,currentRow]==true){
                                                      current2._alpha = 100;
                                                      }else{
                                                                current2._alpha=0;
              //open circle visible on rollover
              current.onRollOver = function() {
                                     this._alpha = 100;
                                     currentCol=(this._x-leftMargin)/(spacing + current._width);
                                     trace("current column ="+currentCol);
                                     currentRow=(this._y-topMargin)/(spacing + current._height);
                                     trace("current row ="+currentRow);
                                     if (drilled[currentCol,currentRow]==false){
                                              trace("Click on the grid point to drill at "+rowLabel[currentRow]+","+colLabel[currentCol]);
                                  }else{
                                              trace("Click on the grid point to review the core at "+rowLabel[currentRow]+","+colLabel[currentCol]);
                                  }     //end 'if-else'
              //open circle invisible on rollout
              current.onRollOut = function() {
                                     this._alpha = 0;
                                     trace("No grid point selected")
              //click on open circle - variable drilled becomes true
              current.onRelease=function(){
                        drilled[currentCol,currentRow]=true;
                        trace(drilled[currentCol,currentRow]);
                        this.removeMovieClip();
    This is an image of the grid showing an 'openCircle' visible when rolled over

    Thanks for the explanation. That was very helpful.
    However, I am having problems with the variables. I did as you suggested though and extended the (grid) layer, but had to create a separate keyframe for the code layer, as that code had to execute first before moving into the next frame. See below (I've also attached the fla, but if you need any more information, please let me know):
    In frame 2 of the animation, if an open circle mc is clicked, that mc is deactivated (removed), drilled becomes true for that coordinate, a filled circle becomes visible in its place and you enter another frame(3) (this is currently just a test frame), to later be used to implement the drilling animation for a clicked coordinate.
    It all seems to be working as it should, until the open circle is clicked and you enter frame 3. See below:
    All the instances of the openCircle mc's are still active in frame 3, so I guess I need to use removeMovieClip(). I know how to do that for a single instance, but howdo I execute that if they're in an array?
    I also don't want any instances of the filledCircles from frame 2 to be visible in frame 3. I'm not sure how to hide them temporarily in frame 3 and then have them visible again in frame 2?
    When I go back to frame 2 (using a back button), all of the filled circles in the array are visible, whereas only the ones that have been previously clicked (drilled = true) should be visible. However, when I return to frame 2 and do a trace to find out which coordinates are set to true/false, it seems that a whole row is now set to (drilled = true), whereas it should just be a single coordinate set to true. Oddly enough, the variable seems to working properly in frame 2 when the code is first executed, but then when I go to frame 3 and then re enter frame 2, it's not working as it should do. Below is the trace code that I've used:
    if (drilled[currentCol,currentRow] == false) {
                                            trace("Click on the grid point to drill at " + rowLabel[currentRow] + "," + colLabel[currentCol]);
                                  } else {
                                            trace("Click on the grid point to review the core at " + rowLabel[currentRow] + "," + colLabel[currentCol]);
    If you could help, I'd be very grateful! Very many thanks.
    http://synergese.co.uk/boreholes15.fla
    Message was edited by: Pippa01
    Sorry, Although the original question was correct, I've just unmarked it as correct. Maybe, I should have started it as a new thread?

  • Problem with an array

    i have problem with my program i implement saveing method
    but when i open file( game.txt) it does not update my board it return same postion every time i same game
    chess class Jframe(Jfilechooser)(call an board array)---->
    Gui Japplet class( call and board array------------>
    Board(class Jpanel have board array)
    it does not update borad array
    it just call it once in start and return the same value every time
    classChess(){
    ChessPlayer  java = new ChessPlayer();
    public  void saveData()
        File file = null;
       JFileChooser fc = new JFileChooser();
       fc.setCurrentDirectory(new File("."));
        fc.setDialogTitle("Save Text As...");
       int returnVal = fc.showSaveDialog(this);
       if (returnVal == JFileChooser.APPROVE_OPTION)
       { file = fc.getSelectedFile();
         try
         { PrintWriter out =
          new PrintWriter(
         new BufferedWriter(
           new FileWriter(file)));
         //while for all the moves in the array>
    for (int i=0;i<120;i++)
         out.println( java.saveDAta(i));
         out.println("\n");
         out.close();
         catch (IOException e) {
              // Some error has occured while trying to read the file.
                // Show an error message.
             JOptionPane.showMessageDialog(this,
                   "Sorry, some error occurred:\n" + e.getMessage());}
    public static void main(String[] args) {
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
         JFrame frame = new ChessMan();
         Container content = frame.getContentPane();
         ChessMan f = new ChessMan();
              //japplet
         ChessPlayer  javaAppletication = new ChessPlayer();
            javaAppletication.init();
            javaAppletication.start();
       }Gui
    [Gui]
    class Gui{
    int [] board = new int [120];
         int [] boardcolor = new int [120];     
    Board check = new Board(this,false);
    {public void init()
         {        // Create new Border
         contentPane = getContentPane();
         bboard = new Board(this,false);
    public String saveDAta(int i)
    String l=check. save(i);
    return (l);
    and finally board Jpanel
    class Board extends JPanel
    {public Board (JApplet useapplet,boolean bool) {
       setup();
    { public String  save(int i)
         {  String l;
                   if (color==1)
                 {System.out.println("notpossible");}
               l =  board[i]+"$"+boardColor;
    return l;
    thanks guys

    My Jframe
    public class ChessMan extends JFrame implements ActionListener, WindowListener  {
    JMenuItem saveItem, loadItem, copyItem, pasteItem; 
    JMenu fileMenu, editMenu; 
    JMenuBar bar;
    ChessPlayer  java = new ChessPlayer();
    public ChessMan()  { setTitle("CHESS PLAYER GAME" );
    setSize(200,300);
    System.out.println("\n");      }
    addWindowListener(new java.awt.event.WindowAdapter()
         {      public void windowClosing(java.awt.event.WindowEvent e)
         {        System.exit(0);      }    });
    JMenu fileMenu = new JMenu("File");
    saveItem = new JMenuItem("Save");
    saveItem.setActionCommand("save");
    saveItem.setAccelerator( KeyStroke.getKeyStroke("ctrl S"));
    saveItem.addActionListener(this);
    fileMenu.add(saveItem);
    loadItem = new JMenuItem("Load");
    loadItem.setActionCommand("load");
    loadItem.setAccelerator( KeyStroke.getKeyStroke("ctrl L"));
    loadItem.addActionListener(this);
    fileMenu.add(loadItem);
    JMenu editMenu = new JMenu("About");
    copyItem = new JMenuItem("Help");
    copyItem.setActionCommand("Help");
    copyItem.setAccelerator( KeyStroke.getKeyStroke("ctrl H"));
    copyItem.addActionListener(this);
    editMenu.add(copyItem);
    pasteItem = new JMenuItem("Exit");
    pasteItem.setActionCommand("Exit");
    pasteItem.setAccelerator( KeyStroke.getKeyStroke("ctrl E"));
    pasteItem.addActionListener(this);
    editMenu.add(pasteItem);
    JMenuBar bar = new JMenuBar();
    bar.add(fileMenu);
    bar.add(editMenu);
    setJMenuBar(bar);
    setVisible(true);
    setLocation(0,0);
    public void actionPerformed(ActionEvent e) {
    JMenuItem item = (JMenuItem)e.getSource();
    String    ac   = item.getActionCommand();
    System.out.println("ac = "+ ac);
    // you can use action commands to track menu item events   
    if(ac.equals("save"))
         {System.out.println("ac.equals(\"save\") = "+ ac.equals("save"));
            saveData();}
    if(ac.equals("load"))
    {System.out.println("ac.equals(\"load\") = "+ ac.equals("load"));
                         loadingData();}
       if(ac.equals("Help"))
    {System.out.println("ac.equals(\"load\") = "+ ac.equals("Help"));
    if(ac.equals("Exit"))
    {System.out.println("ac.equals(\"load\") = "+ ac.equals("Exit"));
                         Exit();}                   
    // the event origin  
    if(item == saveItem)
         System.out.println("item = "+ item.toString().substring
         (item.toString().indexOf("text=") + 5, item.toString().lastIndexOf("]")));
    if(item == loadItem)
         System.out.println("item = "+ item);
    //   System.out.print( java.saveDAta());
    public  void saveData()
        File file = null;
       JFileChooser fc = new JFileChooser();
       fc.setCurrentDirectory(new File("."));
        fc.setDialogTitle("Save Text As...");
       int returnVal = fc.showSaveDialog(this);
       if (returnVal == JFileChooser.APPROVE_OPTION)
       { file = fc.getSelectedFile();
         try
         { PrintWriter out =
          new PrintWriter(
         new BufferedWriter(
           new FileWriter(file)));
         //while for all the moves in the array>
    for (int i=0;i<120;i++)
         out.println( java.saveDAta(i));
         out.println("\n");
         out.close();
         catch (IOException e) {
              // Some error has occured while trying to read the file.
                // Show an error message.
             JOptionPane.showMessageDialog(this,
                   "Sorry, some error occurred:\n" + e.getMessage());}
       public  void loadingData()
       File loadfile = null;
       JFileChooser fc = new JFileChooser();
          fc.setDialogTitle("OpenFile...");
       fc.setCurrentDirectory(new File("."));
        int returnVal = fc.showOpenDialog(this);
       if (returnVal == JFileChooser.APPROVE_OPTION)
       { loadfile = fc.getSelectedFile();
          try
         { PrintWriter out =
         new PrintWriter(
         new BufferedWriter(
           new FileWriter(loadfile)));
         //while for all the moves in the array>
            out.println("�����������������");
         out.println("\n");
         out.close();
         catch (IOException e) {
              // Some error has occured while trying to read the file.
                // Show an error message.
             JOptionPane.showMessageDialog(this,
                   "Sorry, some error occurred:\n" + e.getMessage());}
    public void Exit()
    System.exit(0);
    public static void main(String[] args) {
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
         JFrame frame = new ChessMan();
         Container content = frame.getContentPane();
         ChessMan f = new ChessMan();
         f.setLocation(300,300);
         f.show();
                 ImageIcon customImageIcon = new ImageIcon("ac516.gif");
              Image customImage = customImageIcon.getImage();
              frame.setIconImage(customImage);
                 //japplet
         ChessPlayer  javaAppletication = new ChessPlayer();
         // i could not put my constructor here <Static>     
    javaAppletication.init();
    javaAppletication.start();
    // for(int i=0; i < .length(); i++)
    content.add(javaAppletication, BorderLayout.CENTER);
         frame.getContentPane();
    javaAppletication.setBackground (Color.black);
         frame.setVisible(true);
    frame.show();
    frame.pack(); // invokes getPreferredSize()
    // invokes paint();
    public void windowOpened(WindowEvent e) {
    fileMenu.doClick();
    public void windowClosing(WindowEvent e) {}
    public void windowClosed(WindowEvent e) {}
    public void windowIconified(WindowEvent e) {}
    public void windowDeiconified(WindowEvent e) {}
    public void windowActivated(WindowEvent e) {}
    public void windowDeactivated(WindowEvent e) {}
    My Japplet Class
    class ChessPlayer extends JApplet
         implements ActionListener,MouseListener              
    int c;
         //Reference for new Board
               Board bboard;
         //Reference for Button
             JButton newgame,undo,onePlayer,TwoPlayer,NormalPieceSet,
             FuunyPieceSet,startButton,stopButton;
         //Reference for Label  
              JLabel message;
        //Reference for new Panel
             JPanel buttonpanel2,buttonpanel,messagepanel,buttonpane;
         //Initilize the  Applet
          DemoAnimation Demo;
          Container contentPane;
           Board check = new Board(this,false);
               int [] board = new int [120];
           int [] boardcolor = new int [120];
         public void init()
                   // Create new Border
            contentPane = getContentPane();
         check = new Board(this,false);          
         bboard = new Board(this,false);
         bboard.setPreferredSize(new Dimension(500,400));
        bboard.setBorder(BorderFactory.createLineBorder( Color.red ) ); 
         contentPane.add(bboard);   
         final ImageIcon image = new ImageIcon("ac516.gif");
         bboard.addMouseListener(this);
         bboard.setBackground (Color.black); 
         BorderLayout text=new BorderLayout();
        Demo = new DemoAnimation( this );
         Demo.setPreferredSize(new Dimension(160, 500));
         contentPane.add(Demo);
        // Set Background Black
         contentPane.setBackground (Color.black); 
         contentPane.setLayout (new BorderLayout (50,50));
         // set new Font "TimesRoman"
         Font Text= new Font("TimesRoman", Font.BOLD,15);
         //panel to keep buttons together
         buttonpanel=new JPanel();
         buttonpanel.setLayout(new GridLayout(1,2,6,0));
         buttonpanel.add(newgame=new JButton("new game",image));
         newgame.addActionListener(this);
         buttonpanel.add(undo=new JButton("undo"));
         undo.addActionListener(this);
         // Create new Choice Panel                      
         buttonpanel2 = new JPanel();
         buttonpanel2.setLayout(new GridLayout(6,1,0,10));
         buttonpanel2.add(onePlayer=new JButton("Change Colour"));
         onePlayer.addActionListener(this);
         buttonpanel2.add(TwoPlayer=new JButton("Statistic"));
         TwoPlayer.addActionListener(this);
         buttonpanel2.add(NormalPieceSet=new JButton("Quit"));
         NormalPieceSet.addActionListener(this);
         buttonpanel2.add(FuunyPieceSet=new JButton("Change Piece"));
        FuunyPieceSet.addActionListener(this);
        buttonpanel2.add(startButton = new JButton("Start Animation"));
         startButton.addActionListener(this);
         buttonpanel2.add(stopButton  = new JButton("Stop Animation"));
         stopButton.addActionListener(this);
            contentPane.add(BorderLayout.WEST, demopanel);
    // Set Font For Text Message
         setFont(Text);
         messagepanel=new JPanel();
         messagepanel.setBorder(BorderFactory.createLineBorder( Color.red ) );
         messagepanel.setBackground(Color.black);
    //     essagepanel.setLayout(new GridLayout(1,1));
         // Create new Label
         messagepanel.add(message = new JLabel());               
         setMessage("Welcome");
         // Postion panels in  Layout                
         contentPane.add("North",buttonpanel);
         contentPane.add("East",buttonpanel2);
         contentPane.add ("South",messagepanel);     
         contentPane.add ("Center",bboard);
         contentPane.add("West",Demo);
    public void mouseReleased(java.awt.event.MouseEvent e)
    {  statuseChange();}
    public void mouseClicked(java.awt.event.MouseEvent e)
    public void mouseEntered(java.awt.event.MouseEvent e) {     
    public void mouseExited(java.awt.event.MouseEvent e) {
    public void mouseMoved(java.awt.event.MouseEvent e) {
    statuseChange();
    public void mousePressed(java.awt.event.MouseEvent e)
    {statuseChange();
    public void actionPerformed(ActionEvent e)
         Object source=e.getSource();
         if (source == newgame)
              {  bboard.newgame();
                yellow();
              setMessage("try again");
              pause(100);
              c=add(c);
         else if (source==undo)
                  yellow();
              bboard.undo();
         setMessage("Undo");
         else if (source== TwoPlayer )
              //bboard.setup();
                 yellow(); 
              setMessage("Starting new Game");
         setMessage("Change Color");
         else if(source == FuunyPieceSet)
              {yellow();
              setMessage("game played::" +c);
              bboard.PieceChange();
         else if(source == NormalPieceSet)
              {yellow();
              setMessage("GOODBYE");
              destroy();
          else if(source == startButton)
              {yellow();
              setMessage("Start Animation");
              Demo.start();
         else if(source == stopButton)
              {yellow();
              setMessage("Stop Animation");
              Demo.stop();
              else if(source == onePlayer)
              {setMessage("");
              bboard.changePiece();
              setMessage("Change Color");
           public void statuseChange()
                switch (bboard.gameStatus())
            case 1:
                red();
               setMessage("White won");
           break;
      case 2:
            red();
            setMessage("Black won");
         break;
      case 3:
          red();
           setMessage("DRAW");
         Demo.changeAnimation(2);
           break;
      case 4:
           white();
           setMessage("White Turn");
           Demo.changeAnimation(1);
           break;
      case 5:
           green();
           setMessage("Black turn");
           Demo.changeAnimation(3);
         break;
      case 6:
           red();
            setMessage(" Check");
            Demo.changeAnimation(4);
              break;
      case 7:
           red();
           setMessage("Check");     
            Demo.changeAnimation(4);
            break;
      case 8:
           yellow();
           setMessage("I Hope you enjoyed it");     
    public String saveDAta(int i)
    String l=check.save(i);
    return (l);   
    public void LoadData(String load)
    public void setMessage(String s)
                /*The string s will be shown to the user.*/
         Font Text= new Font("Courier", Font.BOLD,30);
                       message.setText(s);
                       message.setFont(Text);
              public void white()
                   {  message.setForeground(Color.white);}
              public void green()
                     message.setForeground(Color.green);
                   public void red()
                          message.setForeground(Color.red);
                   public void yellow()
                        message.setForeground(Color.yellow);
             //  pause method       
              void pause(int time)
      try {Thread.sleep(time);
    }     catch (InterruptedException e)
         // Create new inset Object
         public Insets getInsets()
         return new Insets(50,220,150,200);
    public void destroy()
    contentPane.remove(buttonpanel2);
    contentPane.remove(buttonpanel);
    contentPane.remove(bboard);
    contentPane.repaint();
    Demo.start();
    public int add(int x)
         { int b=x+1;
          return b;
    }tanx man i dont the other two because they are to long
    my is when i open jframe
    i think Japplet and Jframe can not commuinicate to each other

  • Aperture performance problems with Lacie array

    I have an iMac with 32GB memory and, due to space requirements, an external LaCie 2Big2 disk array, with 2 x 6GB disks in a RAID-1 (mirroring) configuration and attached via USB3.
    This has in the past worked extremely quickly.  The iMac has a 1TB Fusion drive.
    In recent weeks something has changed.  It now takes about a minute for Aperture to start up and open a library of photographs.  It used to take 3-4 seconds.  In the meantime I get a spinning beachball, but can happily use other applications. The manager software for the array says it's working fine.  I am more than a little puzzled and frustrated.
    I'd appreciate suggestions on how to track down the root cause of the problem, and then how to fix it!
    I am on the latest version of Mavericks, with no outstanding software updates.

    Dear Leonie
    Thank you very much for your reply.  Here are the answers:
    What exactly has changed?
         I don't know exactly. Something changes every day on a working system!  However I have not installed any new software or hardware.
    Did this start after a software update?
         Not that I am aware of.  In the last 30 days my only software updates have been Epson driver software, a digital RAW compatibility update to Aperture and a Safari update.  The Aperture update does not apply to any of the equipment I have.
    Or after you moved the library to the Lacie Array?
         No.  I should have been clearer.  The Lacie array was installed several months ago and has been working well.
    Did you import new photos?
         I import new photos almost every day.  However I have several photo libraries and this problem occurs across all of them, even the ones unchanged for months or years.
      Did you enable Photo Stream?
         No
    Does Aperture launch more quickly, if you hold down the Shift key while Aperture is launching?  This will defer the generation of previews.
    If Aperture is launching more quickly this way, you may have imported a corrupted video or image file, that you need to find and to remove.
         No.  I have just tested this.
    Other possible reasons:
    Check the file system on your array. If the filesystem is not MacOS Extended (Journaled), you may have problems with ambigious filenames.
    The file system is MacOS Extended (Journaled)
    Do you have Photo Stream enabled? Aperture may be hanging while trying to load photos from My Photo Stream.
    No, Photo Stream is not enabled.
    Thank you again for your help.

  • Problem with Bytes

    i've recently started learning java, and i am having a few problems with writeing to files.
    for example:
         FileWriter outWriter = new FileWriter("file.txt");
         char i = 1;
    char z = '1'
         outWriter.write(i);
         outWriter.write(z);
         outWriter.close();
    this produces the output '1',
    it doesnt seem a problem untill you want to include loops such as:
    for (int count = 0; count < 100; count++)
    outWriter.write(count);
    this will produce the output '23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abc'
    how would i get it to produce '50 51 52' etc. i have been experimenting and i cant seem to find a solution.
    and sujestions would be very welcome.
    Thanks,
    Xen

    well i wouldn't call it a weakness, it follows the Unicode (3) standard. Therefore all characters (char and Character) have a value assosiated with it.: A = 65, a = 97 etc etc.
    Therefore, when you are using the char i = 1, the value of the "internal int" is set to 1. But when you use '1' the internal int is set to the intvalue that corresponds to the character 1, witch is 49. So the "real" intvalues for your chars are:
    i = 1
    z = 49
    When you write this to your file, and open the file with a texteditor it will translate 1 and 49 to the corresponding cahracters (1 is not a printable cahracter so you get [] insted). If you open the file in a hex-editor, then you would se the values 1 and 49 (probably as 01 and 31 as it will display it in hexvalues).
    Anyhow the proposed solution should work, you can also use the write(String str, int off, int len) - specified by API for OutputStreamWriter - to write a complete String to the file.
    Poul Krogh

  • Problem with byte[].length

    dear sir
    I am working with javacard 2.2.2, windows, jdk 1.5 and JCWDE
    I would like to know the byte length of an array ("aCrypter" in this fallowing code)
    1     public byte[] cryter(byte[] Crypter){
    2
    3          ecipher.init(key, Cipher.MODE_ENCRYPT);
    4          ecipher.doFinal(Crypter, (short)0, (short)aCrypter.length, donneeCrypter , (short)0);
    5          
    6          return donneeCrypter;
    7     }
    JCVM return an error on line 4 (it works with "(short)1"
    there is a solution to know the array length?
    regards
    Alexis
    Edited by: Alexis &amp;quot;le francais&amp;quot; on 21 mars 2011 07:33

    thanks for your help.
    In fact I would like to crypt and after decrypt with this fallowing code:
           private byte[] Crypto = {(byte)0xA0, (byte)0x00,
                 (byte)0x00, (byte)0x00, (byte)0x62, (byte)0x03, (byte)0x01, (byte)0x0C,
                 (byte)0x0f, (byte)0x01, (byte)0x01};
    public void process(APDU apdu) throws ISOException {
              // TODO Auto-generated method stub
              byte[] buffer = apdu.getBuffer();
              if (this.selectingApplet()) return;
              if (buffer[ISO7816.OFFSET_CLA] != CLA_MONAPPLET) {
                   ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
              switch (buffer[ISO7816.OFFSET_INS]) {
                   case INS_INTERROGER_COMPTEUR:
                        tab = new byte[1000];
                        tab[0]= compteur;               
                        tableau = cryter(tab);
                        tableau2= decrypter(tableau);                    
                        apdu.setOutgoing();
                        apdu.setOutgoingLength((short) 7);
                        apdu.sendBytesLong(tableau2,(short) 0, tableau2.lenght);
                        break;          
         public void initialisation(){
            key = (DESKey)KeyBuilder.buildKey(KeyBuilder.TYPE_DES_TRANSIENT_DESELECT,KeyBuilder.LENGTH_DES, false);
            key.setKey(Crypto, (short)0);
            ecipher = Cipher.getInstance(Cipher.ALG_DES_CBC_ISO9797_M2,false);
         public byte[] decrypter(byte[] aDecrypter){
              ecipher.init(key, Cipher.MODE_DECRYPT);
              donneeDecrypte = new byte[10000];
              ecipher.doFinal(aDecrypter, (short)0, (short)aDecrypter.length, donneeDecrypte, (short)0);
              return donneeDecrypte;
         public byte[] cryter(byte[] Crypter){
              ecipher.init(key, Cipher.MODE_ENCRYPT);
              donneeCrypter = new byte[10000];
              ecipher.doFinal(Crypter, (short)0, (short)Crypter.length, donneeCrypter, (short)0);
              return donneeCrypter;
         }Now "crypter" method is executed, but when the debugger is at this fallowing line there is a problem :
    tableau2= decrypter(tableau);maybe the size of the array?
    >
    return ecipher.doFinal(aCrypter);
    >
    I work with Javacard 2.2.2, this method does not exist in the API only :
    abstract short doFinal270(byte[] inBuff, short inOffset, short inLength,byte[] outBuff, short outOffset)Edited by: le francais on 22 mars 2011 03:07

  • Help: Problem With Seperate Arrays Overwriting Each Other!

    Hi,
    I have this function that randomly allocates free time to coursework blocks. This method works because I have tested numerous times and it always prints of different allocations of time every time its called.
    The problem that I have is that I have this method that called this method twice to store each different call within a separate ArrayList.
    When I make the first call the block are assigned to the array fine. But when I called it a second time to store the next result within a separate Array the first Array result are overwritten . Any body have any idea why this is happening, I have asked numerous friends and even my supervisor and he can't find anything wrong with it. Any help would be very helpful...
    Code:
    public ArrayList<CourseworkTimeBlock> courseworkAllocation(ArrayList timetable, ArrayList<CourseworkTimeBlock> cCourseworkBlocks){
              // Calculates and stores the free "time blocks" that can be used
              // to allocate coursework.
              ArrayList<Integer> freeTimeBlocks = new ArrayList<Integer>();
              freeTimeBlocks = freeBlocks(timetable);
              Random random = new Random();
              ArrayList<CourseworkTimeBlock> courseworkTimeBlocks = new ArrayList<CourseworkTimeBlock>();
              for(int i = 0; i < cCourseworkBlocks.size(); i++){
                   int allocateTo = -100;
                   int randomPoint = 0;
                   CourseworkTimeBlock courseworkBlock;
                   courseworkBlock = cCourseworkBlocks.get(i);
                   while(allocateTo < 0){
                        randomPoint = random.nextInt(freeTimeBlocks.size());
                        allocateTo = freeTimeBlocks.get(randomPoint);
                   courseworkBlock.setBlockAllocated(allocateTo);
                   courseworkTimeBlocks.add(courseworkBlock);
                   freeTimeBlocks.set(randomPoint, -1 );
              for( int i = 0; i < courseworkTimeBlocks.size(); i++){
                   System.out.println("CW: " + courseworkTimeBlocks.get(i).getBlockAllocated());
              return courseworkTimeBlocks;
         }These are the calls I make in a separate method:
    ArrayList<CourseworkTimeBlock> courseworkTimetableOne = new ArrayList<CourseworkTimeBlock>();
    ArrayList<CourseworkTimeBlock> courseworkTimetableTwo = new ArrayList<CourseworkTimeBlock>();
             courseworkTimetableOne = courseworkAllocation(fixedTimetable, courseworkBlocks);
             courseworkTimetableTwo = courseworkAllocation(fixedTimetable, courseworkBlocks);Edited by: ChrisUK on Mar 1, 2008 9:11 AM

    ChrisUK wrote:
    Thanks for the reply.
    In terms of the:
    courseworkTimetableOne = courseworkAllocation(fixedTimetable, courseworkBlocks);
    courseworkTimetableTwo = courseworkAllocation(fixedTimetable, courseworkBlocks);They are both supposed to pass in the fixedTimetable object, the reason being is that this is a timetable and is passed through in order to find it "free time" blocks.
    The courseworkTimetableOne and courseworkTimetableTwo are just different representations of how the coursework time blocks could be allocated to that given fixedtimetable. You're calling the same method with the same parameters, so both references are going to point to the same object. It's the same as if you just replaced the second line with courseworkTimetableTwo = courseworkTimetableOne.
    You've got two references pointing to the same object.
    The fact that you do this first:
    ArrayList<CourseworkTimeBlock> courseworkTimetableOne = new ArrayList<CourseworkTimeBlock>();
    ArrayList<CourseworkTimeBlock> courseworkTimetableTwo = new ArrayList<CourseworkTimeBlock>();means nothing. You create the two new ArrayLists, but then this
    courseworkTimetableOne = courseworkAllocation(fixedTimetable, courseworkBlocks);
    courseworkTimetableTwo = courseworkAllocation(fixedTimetable, courseworkBlocks);gets rid of them. The new ArrayLists you just created are lost.
    Remember when you assign to a reference variable such as courseworkTimetableOne =, all that does is copy a reference so now courseworkTimetableOne is pointing to the same object that whatever is on the RHS is pointing to.
    If you want two different lists, then either courseworkAllocation should make a copy of its internal list and return that, or else the caller should do it.
    >
    By the way what does "SSCCE" mean?[http://mindprod.com/jgloss/sscce.html|http://mindprod.com/jgloss/sscce.html]
    [http://homepage1.nifty.com/algafield/sscce.html|http://homepage1.nifty.com/algafield/sscce.html]

  • Problem With Referenced Array Loading

    Hi. I'm working on the final lab for my java class at the moment, and I'm to create a program which reads a file containing transaction records, stores each record as an array element, and then prints various types of reports using the array of transactions. I've created a class called Transaction which stores all the data for each transaction, and the array used in my program is of type Transaction.
    I'm not having any problems in writing the program, except there's something going wrong with my attempt to write a method to load the array. The method declaration is:
    *  Method to accept a file from the user and load its data into an array.
    *  Returns the number of elements added to the array.
    public static int loadArray(Transaction[] transactionArray, int size) throws ExceptionNow, I'm under the impression (and my teacher confirmed this) that arrays are passed by reference. So I'm assuming that by creating an array in my main method, passing it into loadArray(), and changing the values within the method, all the data will be present in the array within main without having to explicitly return the loaded array.
    However, as soon as I try to do anything with the loaded array, I get a NullPointerException. I opened up the debug mode, set a breakpoint in my main right after loadArray() is called, and it shows that every element in my array is null. I am at a loss as to why. If anyone can help me figure out why my reference array isn't staying updated as it's edited elsewhere, it would be greatly appreciated.
    Here is my loadArray() code in case it would help, but there is no error in it's execution, as the same code directly in my main method works fine.
         public static int loadArray(Transaction[] transactionArray, int size) throws Exception
              int logicalSize = 0; // the number of transactions loaded into the array
              int itemID; // the item ID involved in the transaction
              int units; // the number of units in the transaction
              double unitCost; // the cost of each unit in the transaction
              char type; // the type of the transaction
              String date; // the date of the transaction
              String fileName; // the name of the user selected file
              String record; // the current record in the file
              Scanner file; // reads input from a user selected file
              Scanner parse; // reads input from the file's current record
              transactionArray = new Transaction[size]; // creates a new array for the new data
              System.out.print("Please enter a file name: ");
              fileName = input.nextLine();
              file = new Scanner(new File(fileName));
              record = file.nextLine(); // discards the initial line of headers
              while(file.hasNext())
                   // grab the next record and parse all its data
                   record = file.nextLine();
                   parse = new Scanner(record).useDelimiter(",");
                   date = parse.next();
                   itemID = parse.nextInt();
                   type = parse.next().toUpperCase().charAt(0);
                   units = parse.nextInt();
                   unitCost = parse.nextDouble();
                   transactionArray[logicalSize] = new Transaction(date, itemID, type, units, unitCost); // loads the current transaction into the array
                   logicalSize++;
              return logicalSize;
         }Thanks!
    Oh, I guess I should also add that the variable input is a global variable of type Scanner.
    static Scanner input = new Scanner(System.in); // reads input from keyboardMessage was edited by:
    Kristofer.Ward

    Now, I'm under the impression (and my teacher confirmed this) that arrays are
    passed by reference.Java passes references to arrays by value.
    So I'm assuming that by creating an array in my main method, passing it into
    loadArray(), and changing the values within the method, all the data will be present
    in the array within main without having to explicitly return the loaded array.Bearing in mind my statement above, what really happens is that a reference to
    the array you created is passed to loadArray() by value. What I mean by that
    last bit is that your loadArray() is free to assign a reference to a completely
    different array to its argument variable and the caller will not notice the change.
    That's what's happening here:public static int loadArray(Transaction[] transactionArray, int size) throws Exception
        // declarations of local variables
             * The argument variable is now assigned a reference to a completely
             * new array.  When this function returns the variable the caller used to
             * invoke this method will have exactly the same value it did before this
             * method was invoked.  Ie it will *still* refer to an array of nulls.
        transactionArray = new Transaction[size];
        // more stuff - that involves changing the contents of
        // the newly created array, not the one the caller has
        // a reference to.
        return logicalSize;
    }

  • Urgent Please!! Problem with BYTE

    Hi,
    I work with J2ME. I need to decode a binarie file and put the data in a byte[] to create after an image.
    My problem is that i have a negative values (sign) . And its impossible to create an image with that.
    Please can you tell me how can i do???
    Thanks
    Yaney

    Not quite sure what you want to do but
    i = 0-i;
    and
    i *= -1;
    will change the sign of i.

Maybe you are looking for

  • HP Photosmart 7510 doesn't power on

    Hello, I have a hp photo smart 7510 that I bought from your store on Dec 11 2011. It has been working alright until suddenly it doesn't power on. I have checked the cable and I can see power coming through it. Couple of questions: Here's my order num

  • Is there a way to restore an iPod to its factory condition?

    Since the last updater, I havnt been able to connect my iPod to any computer. Im sure the updater corrupted the iPod, so what I would like to do is wipe the iPod clean and start fresh with the factory settings. I know you can restore it using the upd

  • Logical vs. Physical Subnetting

    Hi All, Networks that isolate traffic from other networks using separate mediums are more secure than one that isolates via VLAN correct? So having to networks A and B separate with separate routers, switches, and cabling is more secure than creating

  • JavaScript: changes from CS5.5 to CS6

    Removed Classes FolioBindingDirectionOptions (enum) FolioOrientationOptions (enum) SmoothScrollingOptions (enum) SpaceUnitType (enum) VisibilityInPdf (enum) Properties Button.visibilityInPdf DocumentPreference.masterTextFrame DocumentPreset.masterTex

  • Problem playing .mov files

    Hi, I went to edit a bunch of .mov files this evening and found that all but a few on my hard drive would not play. In finder its giving me the name, the size, the creation date, modified date and last opened date but both dimensions and duration are