Showing posts with label Bluetooth server as swing application that searches bluetooth device in 10 meter circle and show all devices. You can send file to any bluetooth device.. Show all posts
Showing posts with label Bluetooth server as swing application that searches bluetooth device in 10 meter circle and show all devices. You can send file to any bluetooth device.. Show all posts

Saturday 10 August 2013

Top Most Simple GUI bluetooth Server in Swing capability to search all bluetooth device and you can send any type of file in from server to any client device.


/*      */ import java.awt.BorderLayout;
/*      */ import java.awt.Button;
/*      */ import java.awt.Color;
/*      */ import java.awt.Dimension;
/*      */ import java.awt.Frame;
/*      */ import java.awt.Graphics;
/*      */ import java.awt.Image;
/*      */ import java.awt.Panel;
/*      */ import java.awt.Scrollbar;
/*      */ import java.awt.Toolkit;
/*      */ import java.awt.event.ActionEvent;
/*      */ import java.awt.event.ActionListener;
/*      */ import java.awt.event.AdjustmentEvent;
/*      */ import java.awt.event.AdjustmentListener;
/*      */ import java.awt.event.WindowAdapter;
/*      */ import java.awt.event.WindowEvent;
/*      */ import java.io.FileOutputStream;
/*      */ import java.io.IOException;
/*      */ import java.io.InputStream;
/*      */ import java.io.OutputStream;
/*      */ import java.io.PrintStream;
/*      */ import java.util.Hashtable;
/*      */ import java.util.Vector;
/*      */ import javax.bluetooth.DataElement;
/*      */ import javax.bluetooth.LocalDevice;
/*      */ import javax.bluetooth.ServiceRecord;
/*      */ import javax.bluetooth.ServiceRegistrationException;
/*      */ import javax.bluetooth.UUID;
/*      */ import javax.microedition.io.Connector;
/*      */ import javax.microedition.io.StreamConnection;
/*      */ import javax.microedition.io.StreamConnectionNotifier;
/*      */
/*      */ public class teacherBT extends Frame
/*      */   implements Runnable, ActionListener, AdjustmentListener
/*      */ {
/*   33 */   private static final UUID MARKS_SERVER_UUID = new UUID("F0E0D0C0B0A555908070605040302010", false);
/*      */   private static final int SERVICES_NAMES_ATTRIBUTE_ID = 17185;
/*      */   public static final int N_opciones = 3;
/*   39 */   int alturarect = 0;
/*   40 */   private Thread pp_hilo = null;
/*      */   teacherBT.BTMarksServer bt;
/*   42 */   int[] acus = new int[7];
/*   43 */   public String servicioelegido = "";
/*   44 */   int[] acusops = new int[7];
/*      */   public Graphics gBuffer;
/*      */   public Image imag;
/*   48 */   int ANCHO = 800;
/*   49 */   int ALTO = 600;
/*      */   int ancho;
/*      */   int alto;
/*   51 */   int[] unos = new int[7];
/*   52 */   int[] ceros = new int[7];
/*   53 */   int[] vacios = new int[7];
/*      */
/*   55 */   private int tempo = 10;
/*      */
/*   57 */   public int interact = 1;
/*      */
/*   59 */   public double t = 7.85398D;
/*   60 */   public double Max_t = 100.0D;
/*   61 */   public double Min_t = -100.0D;
/*      */   Image fondo;
/*      */   Image cero;
/*      */   Image uno;
/*      */   Image dos;
/*      */   Image tres;
/*      */   Image cuatro;
/*      */   Image cinco;
/*   66 */   public Button boton = new Button("Ratings Monitor - Options - Questions");
/*      */
/*   68 */   public Button boton2 = new Button("Interact");
/*      */
/*   72 */   public Scrollbar sbh = new Scrollbar(0, 0, 0, 0, 100);
/*   73 */   public Scrollbar sbv = new Scrollbar(1, 0, 0, 0, 100);
/*   74 */   public Scrollbar sbva = new Scrollbar(1, 0, 0, 0, 100);
/*      */
/*   76 */   public boolean ani = false;
/*      */
/*      */   public teacherBT(String[] paramArrayOfString)
/*      */   {
/*   83 */     super("LIQVID Bluetooth Polling Data Collection");
/*      */
/*   85 */     setSize(this.ANCHO, this.ALTO);
/*      */
/*   87 */     addWindowListener(new teacherBT.CierredeVentana());
/*      */
/*   89 */     for (int i = 0; i <= 6; ++i) { this.acus[i] = 0;
/*   90 */       this.acusops[i] = 0;
/*   91 */       this.unos[i] = 0;
/*   92 */       this.ceros[i] = 0;
/*   93 */       this.vacios[i] = 0;
/*      */     }
/*      */
/*   96 */     Panel localPanel = new Panel();
/*      */
/*   98 */     localPanel.setLayout(new BorderLayout());
/*   99 */     setLayout(new BorderLayout());
/*  100 */     add(localPanel, "South");
/*      */
/*  103 */     localPanel.add(this.boton, "North");
/*  104 */     this.boton.addActionListener(this);
/*      */
/*  110 */     add(this.sbh, "North");
/*      */
/*  114 */     this.sbh.addAdjustmentListener(this);
/*      */
/*  120 */     this.sbh.setValue(25);
/*      */
/*  126 */     setBackground(Color.white);
/*      */
/*  128 */     this.ancho = getSize().width;
/*  129 */     this.alto = getSize().height;
/*      */
/*  132 */     this.pp_hilo = new Thread(this);
/*  133 */     this.pp_hilo.start();
/*  134 */     show();
/*      */     try
/*      */     {
/*  137 */       this.bt = new teacherBT.BTMarksServer(this, paramArrayOfString);
/*      */     }
/*      */     catch (Exception localException) {
/*  140 */       System.out.println("Exception Occured: " + localException.toString());
/*      */     }
/*      */
/*  143 */     Toolkit localToolkit = Toolkit.getDefaultToolkit();
/*      */
/*  145 */     this.fondo = localToolkit.getImage("Wm123.png");
/*      */
/*  148 */     this.cero = localToolkit.getImage("cero.png");
/*  149 */     this.uno = localToolkit.getImage("uno.png");
/*  150 */     this.dos = localToolkit.getImage("dos.png");
/*  151 */     this.tres = localToolkit.getImage("tres.png");
/*  152 */     this.cuatro = localToolkit.getImage("cuatro.png");
/*  153 */     this.cinco = localToolkit.getImage("cinco.png");
/*      */   }
/*      */
/*      */   public void actionPerformed(ActionEvent paramActionEvent)
/*      */   {
/*  163 */     Button localButton = (Button)paramActionEvent.getSource();
/*  164 */     if (localButton.equals(this.boton)) {
/*  165 */       this.interact = ((1 + this.interact) % 3);
/*      */     }
/*  173 */     else if (!(localButton.equals(this.boton2)))
/*      */       return;
/*      */   }
/*      */
/*      */   public void adjustmentValueChanged(AdjustmentEvent paramAdjustmentEvent)
/*      */   {
/*  183 */     Scrollbar localScrollbar = (Scrollbar)paramAdjustmentEvent.getSource();
/*  184 */     int i = localScrollbar.getValue();
/*  185 */     if (localScrollbar.equals(this.sbh)) {
/*  186 */       if (this.interact != 1)
/*      */         return;
/*      */     }
/*  189 */     else if ((!(localScrollbar.equals(this.sbv))) ||
/*  190 */       (this.interact != 1))
/*      */       return;
/*      */   }
/*      */
/*      */   public void destroy()
/*      */   {
/*      */   }
/*      */
/*      */   public void paint(Graphics paramGraphics)
/*      */   {
/*  209 */     displayImage(paramGraphics);
/*      */   }
/*      */
/*      */   private void displayImage(Graphics paramGraphics)
/*      */   {
/*  223 */     String str = "Received " + this.acus[6] + " Connections";
/*  224 */     int i = 150;
/*  225 */     double d = 1.0D;
/*  226 */     if (this.interact == 1) str = str + "   Monitor Ratings";
/*  228 */     else if (this.interact == 2) str = str + "   Monitor Options";
/*      */     else
/*      */     {
/*  231 */       str = str + "   Monitor Issues";
/*      */     }
/*      */
/*  234 */     paramGraphics.setColor(Color.black);
/*  235 */     paramGraphics.drawString(str, this.ancho / 10, 37 * this.alto / 40);
/*  236 */     paramGraphics.drawLine(this.ancho / 10, this.alto * 4 / 5 + 2, 9 * this.ancho / 10, this.alto * 4 / 5 + 2);
/*  237 */     paramGraphics.drawLine(this.ancho / 10, this.alto * 1 / 10 - 2, 9 * this.ancho / 10, this.alto * 1 / 10 - 2);
/*      */
/*  239 */     for (int j = 0; j <= 5; ++j) {
/*  240 */       if (j == 0) { paramGraphics.setColor(new Color(255, 0, 0, i));
/*  241 */         paramGraphics.drawImage(this.cero, this.ancho / 12 + this.ancho * j / 7 + this.ancho / 16 - 5, this.alto * 17 / 20 - 15, this); }
/*  242 */       if (j == 1) { paramGraphics.setColor(new Color(0, 153, 204, i));
/*  243 */         paramGraphics.drawImage(this.uno, this.ancho / 12 + this.ancho * j / 7 + this.ancho / 16 - 5, this.alto * 17 / 20 - 15, this); }
/*  244 */       if (j == 2) { paramGraphics.setColor(new Color(255, 102, 0, i));
/*  245 */         paramGraphics.drawImage(this.dos, this.ancho / 12 + this.ancho * j / 7 + this.ancho / 16 - 5, this.alto * 17 / 20 - 15, this); }
/*  246 */       if (j == 3) { paramGraphics.setColor(new Color(92, 204, 97, i));
/*  247 */         paramGraphics.drawImage(this.tres, this.ancho / 12 + this.ancho * j / 7 + this.ancho / 16 - 5, this.alto * 17 / 20 - 15, this); }
/*  248 */       if (j == 4) { paramGraphics.setColor(new Color(255, 204, 51, i));
/*  249 */         paramGraphics.drawImage(this.cuatro, this.ancho / 12 + this.ancho * j / 7 + this.ancho / 16 - 5, this.alto * 17 / 20 - 15, this); }
/*  250 */       if (j == 5) { paramGraphics.setColor(new Color(0, 80, 213, i));
/*  251 */         paramGraphics.drawImage(this.cinco, this.ancho / 12 + this.ancho * j / 7 + this.ancho / 16 - 5, this.alto * 17 / 20 - 15, this); }
/*  252 */       if (this.interact > 0)
/*      */       {
/*  254 */         if ((this.interact == 1) &&
/*  255 */           (this.acus[6] > 0)) {
/*  256 */           d = (1.0D * this.sbh.getValue() - 0.0D) / 25.0D;
/*      */
/*  258 */           paramGraphics.fillRect(this.ancho / 12 + this.ancho * j / 7, this.alto * 4 / 5 - (int)(0.7D * d * this.alto * this.acus[j] / this.acus[6]), this.ancho / 8, (int)(0.7D * d * this.alto * this.acus[j] / this.acus[6]));
/*      */         }
/*      */
/*  263 */         if ((this.interact != 2) ||
/*  264 */           (this.acusops[6] <= 0)) continue;
/*  265 */         d = (1.0D * this.sbh.getValue() - 0.0D) / 25.0D;
/*      */
/*  267 */         paramGraphics.fillRect(this.ancho / 12 + this.ancho * j / 7, this.alto * 4 / 5 - (int)(0.7D * d * this.alto * this.acusops[j] / this.acusops[6]), this.ancho / 8, (int)(0.7D * d * this.alto * this.acusops[j] / this.acusops[6]));
/*      */       }
/*  275 */       else if (this.acus[6] > 0) {
/*  276 */         d = (1.0D * this.sbh.getValue() - 0.0D) / 25.0D;
/*  277 */         paramGraphics.setColor(new Color(0, 80, 213, i));
/*  278 */         paramGraphics.fillRect(this.ancho / 12 + this.ancho * j / 7, this.alto * 4 / 5 - (int)(0.7D * d * this.alto * this.unos[j] / this.acus[6]), this.ancho / 30, (int)(0.7D * d * this.alto * this.unos[j] / this.acus[6]));
/*  279 */         paramGraphics.setColor(new Color(255, 0, 0, i));
/*  280 */         paramGraphics.fillRect(this.ancho / 12 + this.ancho * j / 7 + this.ancho / 24, this.alto * 4 / 5 - (int)(0.7D * d * this.alto * this.ceros[j] / this.acus[6]), this.ancho / 30, (int)(0.7D * d * this.alto * this.ceros[j] / this.acus[6]));
/*  281 */         paramGraphics.setColor(new Color(92, 204, 97, i));
/*  282 */         paramGraphics.setColor(new Color(255, 204, 51, i));
/*  283 */         paramGraphics.fillRect(this.ancho / 12 + this.ancho * j / 7 + 2 * this.ancho / 24, this.alto * 4 / 5 - (int)(0.7D * d * this.alto * this.vacios[j] / this.acus[6]), this.ancho / 30, (int)(0.7D * d * this.alto * this.vacios[j] / this.acus[6]));
/*      */       }
/*      */     }
/*      */   }
/*      */
/*      */   public void start()
/*      */   {
/*  306 */     if (this.pp_hilo != null)
/*      */       return;
/*  308 */     this.pp_hilo = new Thread(this);
/*  309 */     this.pp_hilo.start();
/*      */   }
/*      */
/*      */   public void stop()
/*      */   {
/*  317 */     if (this.pp_hilo == null) {
/*      */       return;
/*      */     }
/*  320 */     this.pp_hilo = null;
/*      */   }
/*      */
/*      */   public void update(Graphics paramGraphics)
/*      */   {
/*  329 */     if (this.gBuffer == null) {
/*  330 */       this.imag = createImage(this.ancho, this.alto);
/*  331 */       this.gBuffer = this.imag.getGraphics();
/*      */     }
/*  333 */     this.gBuffer.setColor(getBackground());
/*  334 */     this.gBuffer.fillRect(0, 0, this.ancho, this.alto);
/*  335 */     this.gBuffer.drawImage(this.fondo, 165, 70, this);
/*  336 */     displayImage(this.gBuffer);
/*  337 */     paramGraphics.drawImage(this.imag, 0, 0, null);
/*      */   }
/*      */
/*      */   public void run()
/*      */   {
/*      */     while (true)
/*      */     {
/*      */       try
/*      */       {
/*  355 */         this.t += 5.0D;
/*  356 */         if (this.t > this.Max_t) this.t = this.Min_t;
/*      */
/*  361 */         Thread.sleep(this.tempo);
/*      */       }
/*      */       catch (InterruptedException localInterruptedException)
/*      */       {
/*  366 */         stop();
/*      */       }
/*  368 */       repaint();
/*      */     }
/*      */   }
/*      */
/*      */   public static void main(String[] paramArrayOfString)
/*      */   {
/*  375 */     teacherBT localteacherBT = new teacherBT(paramArrayOfString);
/*      */   }
/*      */
/*      */   final class BTMarksServer
/*      */     implements Runnable
/*      */   {
/*      */     private LocalDevice localDevice;
/*  391 */     public Double[] Q = new Double[5];
/*      */     public int matricula;
/*      */     public int formulario;
/*  393 */     public int notafinal = 0;
/*  394 */     public String fich = "";
/*      */     private StreamConnectionNotifier notifier;
/*      */     private ServiceRecord record;
/*      */     public teacherBT parent;
/*      */     private boolean isClosed;
/*      */     private Thread accepterThread;
/*      */     private teacherBT.BTMarksServer.enCola processor;
/*  419 */     private final Hashtable dataElements = new Hashtable();
/*      */     public String[] ar;
/*      */
/*      */     BTMarksServer(teacherBT paramteacherBT, String[] paramArrayOfString)
/*      */     {
/*  430 */       this.ar = paramArrayOfString;
/*  431 */       this.parent = paramteacherBT;
/*      */
/*  436 */       this.accepterThread = new Thread(this);
/*  437 */       this.accepterThread.start();
/*      */     }
/*      */
/*      */     public void run()
/*      */     {
/*  445 */       int i = 0;
/*      */       try
/*      */       {
/*  449 */         this.localDevice = LocalDevice.getLocalDevice();
/*      */
/*  452 */         if (!(this.localDevice.setDiscoverable(10390323)));
/*  459 */         StringBuffer localStringBuffer = new StringBuffer("btspp://");
/*      */
/*  462 */         localStringBuffer.append("localhost").append(':');
/*      */
/*  465 */         localStringBuffer.append(teacherBT.MARKS_SERVER_UUID.toString());
/*      */
/*  468 */         localStringBuffer.append(";name=BTMarksServer");
/*      */
/*  472 */         localStringBuffer.append(";authorize=false");
/*      */
/*  475 */         this.notifier = ((StreamConnectionNotifier)Connector.open(localStringBuffer.toString()));
/*      */
/*  478 */         this.record = this.localDevice.getRecord(this.notifier);
/*      */
/*  481 */         DataElement localDataElement = new DataElement(48);
/*  482 */         this.record.setAttributeValue(17185, localDataElement);
/*      */
/*  485 */         i = 1;
/*      */       } catch (Exception localException) {
/*  487 */         System.err.println("Can't initialize bluetooth: " + localException);
/*      */       }
/*      */
/*  493 */       if (i == 0) {
/*  494 */         return;
/*      */       }
/*      */
/*  498 */       this.processor = new teacherBT.BTMarksServer.enCola();
/*      */
/*  500 */       if (this.ar.length > 0) {
/*  501 */         for (int j = 0; j < this.ar.length; ++j)
/*  502 */           changeImageInfo(this.ar[j], true);
/*      */       }
/*      */       else
/*      */       {
/*  506 */         changeImageInfo("Active Participation", true);
/*  507 */         changeImageInfo("Final Test", true);
/*  508 */         changeImageInfo("BT Survey", true);
/*  509 */         changeImageInfo("Election of Delegates", true);
/*      */       }
/*  511 */       System.out.println("Proofreader ready");
/*      */
/*  515 */       //while (!(this.isClosed)) {
/*  516 */        // label249: StreamConnection localStreamConnection = null;
/*      */        // try
/*      */        // {
/*  519 */        //   localStreamConnection = this.notifier.acceptAndOpen();
/*      */        // }
/*      */        // catch (IOException localIOException) {
/*  522 */        //   break label249:
/*      */        // }
/*      */
/*  525 */        // this.processor.addConnection(localStreamConnection);
/*      */      // }
do
   {
        if(this.isClosed)
             break;
             StreamConnection localStreamconnection = null;
           try
               {
                   localStreamconnection = this.notifier.acceptAndOpen();
               }
               catch(IOException ioexception)
               {
                   continue;
               }
               this.processor.addConnection(localStreamconnection);
    } while(true);

/*      */     }
/*      */
/*      */     boolean changeImageInfo(String paramString, boolean paramBoolean)
/*      */     {
/*  540 */       DataElement localDataElement1 = this.record.getAttributeValue(17185);
/*      */
/*  543 */       DataElement localDataElement2 = (DataElement)this.dataElements.get(paramString);
/*      */
/*  546 */       if (localDataElement2 == null) {
/*  547 */         localDataElement2 = new DataElement(32, paramString);
/*  548 */         this.dataElements.put(paramString, localDataElement2);
/*      */       }
/*      */
/*  552 */       if (paramBoolean) {
/*  553 */         localDataElement1.addElement(localDataElement2);
/*      */       }
/*  555 */       else if (!(localDataElement1.removeElement(localDataElement2))) {
/*  556 */         System.err.println("Error: item was not removed for: " + paramString);
/*      */
/*  558 */         return false;
/*      */       }
/*      */
/*  562 */       this.record.setAttributeValue(17185, localDataElement1);
/*      */       try
/*      */       {
/*  565 */         this.localDevice.updateRecord(this.record);
/*      */       } catch (ServiceRegistrationException localServiceRegistrationException) {
/*  567 */         System.err.println("Can't update record now for: " + paramString);
/*      */
/*  569 */         return false;
/*      */       }
/*      */
/*  572 */       return true;
/*      */     }
/*      */
/*      */     void destroy()
/*      */     {
/*  580 */       this.isClosed = true;
/*      */
/*  583 */       if (this.notifier != null)
/*      */         try {
/*  585 */           this.notifier.close();
/*      */         }
/*      */         catch (IOException localIOException)
/*      */         {
/*      */         }
/*      */       try
/*      */       {
/*  592 */         this.accepterThread.join();
/*      */       }
/*      */       catch (InterruptedException localInterruptedException)
/*      */       {
/*      */       }
/*  597 */       if (this.processor != null) {
/*  598 */         this.processor.destroy(true);
/*      */       }
/*      */
/*  601 */       this.processor = null;
/*      */     }
/*      */
/*      */     private void processConnection(StreamConnection paramStreamConnection)
/*      */     {
/*  611 */       String str = readImageName(paramStreamConnection);
/*  612 */       System.out.println("Application=" + str);
/*      */
/*  624 */       sendImageData(paramStreamConnection);
/*      */       try
/*      */       {
/*  628 */         paramStreamConnection.close();
/*      */       }
/*      */       catch (IOException localIOException)
/*      */       {
/*      */       }
/*      */     }
/*      */
/*      */     private void sendImageData(StreamConnection paramStreamConnection)
/*      */     {
/*  641 */       OutputStream localOutputStream = null;
/*      */
/*  648 */       int i = 19;
/*  649 */       i = this.notafinal;
/*      */       try {
/*  651 */         localOutputStream = paramStreamConnection.openOutputStream();
/*      */
/*  653 */         localOutputStream.write(i >> 8);
/*  654 */         localOutputStream.write(i & 0xFF);
/*      */
/*  656 */         localOutputStream.flush();
/*      */         try
/*      */         {
/*      */           try
/*      */           {
/*  663 */             FileOutputStream localFileOutputStream = new FileOutputStream(this.fich);
/*      */
/*  665 */             localFileOutputStream.close();
/*      */           }
/*      */           catch (IOException localIOException1) {
/*      */           }
/*  669 */           Thread.sleep(1000L);
/*      */         }
/*      */         catch (InterruptedException localInterruptedException)
/*      */         {
/*      */         }
/*      */       }
/*      */       catch (IOException localIOException2) {
/*  676 */         System.err.println("Can't send image data: " + localIOException2);
/*      */       }
/*      */
/*  691 */       if (localOutputStream == null) return;
/*      */       try {
/*  693 */         localOutputStream.close();
/*      */       } catch (IOException localIOException3) {
/*  695 */         System.err.println("Can't close conn: " + localIOException3);
/*      */       }
/*      */     }
/*      */
/*      */     private String readImageName(StreamConnection paramStreamConnection)
/*      */     {
/*  704 */       String str1 = null;
/*  705 */       String str2 = "";
/*  706 */       InputStream localInputStream = null;
/*      */       try
/*      */       {
/*  709 */         localInputStream = paramStreamConnection.openInputStream();
/*      */
/*  711 */         int i = localInputStream.read();
/*      */
/*  713 */         if (i <= 0) {
/*  714 */           throw new IOException("Can't read name length");
/*      */         }
/*      */
/*  717 */         byte[] arrayOfByte = new byte[i];
/*  718 */         i = 0;
/*      */
/*  720 */         while (i != arrayOfByte.length) {
/*  721 */           int j = localInputStream.read(arrayOfByte, i, arrayOfByte.length - i);
/*      */
/*  723 */           if (j == -1) {
/*  724 */             throw new IOException("Can't read name data");
/*      */           }
/*      */
/*  727 */           i += j;
/*      */         }
/*      */
/*  730 */         str1 = new String(arrayOfByte);
/*      */
/*  736 */         this.notafinal = 0;
/*      */
/*  738 */         String str3 = valor(str1, ";m");
/*  739 */         this.fich = "M_" + str3 + "_";
/*      */         try {
/*  741 */           this.matricula = Integer.valueOf(str3).intValue();
/*      */         }
/*      */         catch (Exception localException1) {
/*  744 */           this.matricula = 0;
}
/*  745 */         str3 = valor(str1, ";f");
/*  746 */         this.fich = this.fich + str3 + "_";
/*      */         try {
/*  748 */           this.formulario = Integer.valueOf(str3).intValue();
/*      */         }
/*      */         catch (Exception localException2) {
/*  751 */           this.formulario = 0;
/*      */         }
/*      */
/*  754 */         str3 = valor(str1, ";u");
/*  755 */         this.fich = this.fich + str3 + "_";
/*  756 */         str2 = valor(";o=" + str1, ";o");
/*  757 */         this.fich = this.fich + str2 + "_";
/*  758 */         int k = 0;
/*  759 */         String str4 = "";
/*  760 */         int l = 0;
/*  761 */         for (int j = 1; j < 6; ++j) {
/*  762 */           str3 = valor(str1, "Q" + j);
/*  763 */           this.fich = this.fich + str3 + "_";
/*      */           try {
/*  765 */             this.Q[(j - 1)] = Double.valueOf(Double.valueOf(str3).doubleValue());
/*  766 */             l = evalua(j, this.Q[(j - 1)].doubleValue(), this.matricula, this.formulario, str2);
/*      */             BTMarksServer tmp459_458 = this; tmp459_458.notafinal = (int)(tmp459_458.notafinal + Math.pow(2.0D, j - 1) * l);
/*  768 */             k += l;
/*  769 */             str4 = str4 + l;
/*  770 */             if (l == 1)
/*  771 */               teacherBT.this.unos[j] += 1;
/*      */             else
/*  773 */               teacherBT.this.ceros[j] += 1;
/*      */           }
/*      */           catch (Exception localException3) {
/*  776 */             this.Q[(j - 1)] = Double.valueOf(0.0D);
/*  777 */             str4 = str4 + "0";
/*  778 */             teacherBT.this.vacios[j] += 1;
/*      */           }
/*      */
/*      */         }
/*      */
/*  783 */         this.fich = this.fich + "X_" + str4 + "_N_" + k + ".txt";
/*  784 */         this.parent.acus[k] += 1;
/*  785 */         if ((this.formulario >= 0) && (this.formulario <= 5)) this.parent.acusops[this.formulario] += 1;
/*  786 */         if (this.formulario == 1) teacherBT.this.unos[0] += 1;
/*  787 */         if (this.formulario == 0) teacherBT.this.ceros[0] += 1;
/*  788 */         if (this.formulario == 2) teacherBT.this.vacios[0] += 1;
/*  789 */         if (this.parent.interact == 2) this.notafinal = 1;
/*      */
/*  791 */         this.parent.acus[6] += 1;
/*  792 */         this.parent.acusops[6] += 1;
/*      */       }
/*      */       catch (IOException localIOException1)
/*      */       {
/*  798 */         System.err.println(localIOException1);
/*      */       }
/*      */
/*  802 */       if (localInputStream != null)
/*      */         try {
/*  804 */           localInputStream.close();
/*      */         }
/*      */         catch (IOException localIOException2)
/*      */         {
/*      */         }
/*  809 */       return str1;
/*      */     }
/*      */
/*      */     public String valor(String paramString1, String paramString2)
/*      */     {
/*  926 */       String str = paramString1.substring(paramString1.indexOf(paramString2 + "="));
/*  927 */       str = str.substring(str.indexOf("="));
/*      */
/*  929 */       str = str.substring(1, str.indexOf(";"));
/*  930 */       str = str.trim();
/*      */
/*  932 */       return str;
/*      */     }
/*      */
/*      */     private String leeCadena(StreamConnection paramStreamConnection) {
/*  936 */       String str = null;
/*  937 */       InputStream localInputStream = null;
/*      */       try
/*      */       {
/*  940 */         localInputStream = paramStreamConnection.openInputStream();
/*      */
/*  942 */         int i = localInputStream.read();
/*      */
/*  944 */         if (i <= 0) {
/*  945 */           throw new IOException("Can't read name length");
/*      */         }
/*      */
/*  948 */         byte[] arrayOfByte = new byte[i];
/*  949 */         i = 0;
/*      */
/*  951 */         while (i != arrayOfByte.length) {
/*  952 */           int j = localInputStream.read(arrayOfByte, i, arrayOfByte.length - i);
/*      */
/*  954 */           if (j == -1) {
/*  955 */             throw new IOException("Can't read name data");
/*      */           }
/*      */
/*  958 */           i += j;
/*      */         }
/*      */
/*  961 */         str = new String(arrayOfByte);
/*      */       }
/*      */       catch (IOException localIOException1)
/*      */       {
/*  965 */         System.err.println(localIOException1);
/*      */       }
/*      */
/*  969 */       if (localInputStream != null)
/*      */         try {
/*  971 */           localInputStream.close();
/*      */         }
/*      */         catch (IOException localIOException2)
/*      */         {
/*      */         }
/*  976 */       return str;
/*      */     }
/*      */
/*      */     public void escribeCadena(StreamConnection paramStreamConnection, String paramString) {
/*      */       try {
/*  981 */         OutputStream localOutputStream = paramStreamConnection.openOutputStream();
/*  982 */         localOutputStream.write(paramString.length());
/*  983 */         localOutputStream.write(paramString.getBytes());
/*  984 */         localOutputStream.flush();
/*  985 */         localOutputStream.close();
/*      */       } catch (IOException localIOException1) {
/*  987 */         System.err.println("Can't write to server ");
/*      */         try
/*      */         {
/*  991 */           paramStreamConnection.close();
/*      */         }
/*      */         catch (IOException localIOException2) {
/*      */         }
/*      */       }
/*      */     }
/*      */
/*      */     public int evalua(int paramInt1, double paramDouble, int paramInt2, int paramInt3, String paramString) {
/*  999 */       int i = BTGrader.grade(paramInt1, paramDouble, paramInt2, paramInt3, paramString);
/* 1000 */       return i;
/*      */     }
/*      */
/*      */     private class enCola
/*      */       implements Runnable
/*      */     {
/*      */       private Thread processorThread;
/*  849 */       private Vector queue = new Vector();
/*  850 */       private boolean isOk = true;
/*      */
/*      */       enCola() {
/*  853 */         this.processorThread = new Thread(this);
/*  854 */         this.processorThread.start();
/*      */
/*  856 */         System.out.println("New process");
/*      */       }
/*      */
/*      */       public void run()
/*      */       {
/*  861 */         while (!(teacherBT.BTMarksServer.this.isClosed))
/*      */         {
/*  863 */           synchronized (this) {
/*  864 */             if (this.queue.size() == 0) {
/*      */               try {
/*  866 */                 super.wait();
/*      */               } catch (InterruptedException localInterruptedException) {
/*  868 */                 System.err.println("Unexpected exception: " + localInterruptedException);
/*  869 */                 destroy(false);
/*      */
/*  871 */                 return;
/*      */               }
/*      */
/*      */             }
/*      */
/*      */           }
/*      */
/*  879 */           synchronized (this)
/*      */           {
/*  881 */             if (teacherBT.BTMarksServer.this.isClosed) {
/*  882 */               return;
/*      */             }
/*      */
/*  885 */             StreamConnection streamconnection = (StreamConnection)this.queue.firstElement();
/*  886 */             this.queue.removeElementAt(0);
/*  887 */             teacherBT.BTMarksServer.this.processConnection((StreamConnection)streamconnection);
/*      */           }
/*      */         }
/*      */       }
/*      */
/*      */       void addConnection(StreamConnection paramStreamConnection)
/*      */       {
/*  894 */         synchronized (this) {
/*  895 */           this.queue.addElement(paramStreamConnection);
/*  896 */           super.notify();
/*      */         }
/*      */       }
/*      */
/*      */       void destroy(boolean paramBoolean)
/*      */       {
/*  904 */         synchronized (this) {
/*  905 */           super.notify();
/*      */
/*  907 */           while (this.queue.size() != 0) {
/*  908 */             StreamConnection localStreamConnection = (StreamConnection)this.queue.firstElement();
/*  909 */             this.queue.removeElementAt(0);
/*      */             try
/*      */             {
/*  912 */               localStreamConnection.close();
/*      */             }
/*      */             catch (IOException localIOException)
/*      */             {
/*      */             }
/*      */           }
/*      */         }
/*      */         try {
/*  920 */           this.processorThread.join();
/*      */         }
/*      */         catch (InterruptedException localInterruptedException)
/*      */         {
/*      */         }
/*      */       }
/*      */     }
/*      */   }
/*      */
/*      */   class CierredeVentana extends WindowAdapter
/*      */   {
/*      */     public void windowClosing(WindowEvent paramWindowEvent)
/*      */     {
/*  379 */       System.exit(0);
/*      */     }
/*      */   }
/*      */ }

LinkWithin

Related Posts Plugin for WordPress, Blogger...

Labels

Core Java programming core java interview question Core Java Faq's Servlets coding database jsp-servlet spring Java linux unix interview questions java investment bank Web Services Interview investment bank mysql Senior java developer interviews best practices java collection tutorial RMI SQL Eclipse FIX protocol tutorial tibco J2EE groovy java questions SCJP grails java 5 tutorial jdbc beginner error and exception Design Patterns Java Programming Tutorials fundamentals general object oriented programming xml Java Programs Hibernate Examples Flex JAMon Java xml tutorial logging Jsp Struts 2.0 Sybase and SQL Server debugging java interviews performance FIX Protocol interview questions JUnit testing WebSphere date and time tutorial experienced java IO tutorial java concurrency thread Ejb Freshers Papers IT Management Java Exapmle Java Script SQL and database tutorial examples Scwcd ant tutorials concurrency example and tutorial future state homework java changes java threading tricky Agile Business of IT Development JSTL Java JSON tutorial Java multithreading Tutorials PM Scrum data structure and algorithm java puzzles java tips testing tips windows 8 5 way to create Singleton Object Architect Interview Questions and Answers Architecture Architecure Bluetooth server as swing application that searches bluetooth device in 10 meter circle and show all devices. You can send file to any bluetooth device. C Programming CIO Callable Statement in Java Circular dependency of Objects in Java Comparable Example in Collection Custom annotation in Java Developer Interview Divide and rule example in java Drupal Example of Singleton Pattern FIX protocol ForkJoin Example in Java 7 Get data from dynamic table with Java Script Git HTML and JavaScript Health Hello World TCP Client Server Networking Program Hibernate Basics Hibernate Interview Question Answer J2EE Interview Question And Answers J2ME GUI Program JEE Interview QA JMS interview question Java J2EE Hibernate Spring Struts Interview Question Java System Property Java Threads Manager Portlets Provident Fund Read data from any file in same location and give the required result. Reading Properties File in Java Redpoint Rest WebService Client Rest Webservice Test SAL join with ven diagram SCP UNIX COMMAND SSL Singleton Pattern in Java Spring Bean Initialization methods and their order Spring Interview Questions Struts Struts 2.0 Basics Struts 2.0 Design Pattern Submit Html Form With Java Script On The Fly Unix executable For Java Program XOM DOM SAX XP books computers core java; core java; object oriented programming data structure; java investment bank; design pattern dtd duplicate rows in table get browser name with jquery grails podcast inner class java beginners tutorial java cache java networking tutorial java spring java util; java collections; java questions java.java1.5 linked list mailto function with all browser oracle database oracle duplicate rows orm schema social spring mvc questions struts transaction tricks tweet windows xslt