Example #1
1
  // --------------------------------actionConnect------------------------------
  private void actionConnect() {
    if (oParty == null) {
      JOptionPane.showMessageDialog(frame, "Make a party before trying to connect.");
      return;
    }

    String[] oResults = (String[]) DialogManager.show(DialogManager.CONNECT, frame);

    if (oResults[DialogManager.RETURN_IP].equals("cancel")) return;

    lblStatus3.setText("Connecting...");
    try {
      oConn.connect(
          oResults[DialogManager.RETURN_IP], Integer.parseInt(oResults[DialogManager.RETURN_PORT]));
    } catch (UnknownHostException e) {
      JOptionPane.showMessageDialog(
          frame,
          "The IP of the host cannot be determined.",
          "Unknown Host Exception",
          JOptionPane.ERROR_MESSAGE);
      frame.repaint();
      return;
    } catch (IOException e) {
      JOptionPane.showMessageDialog(
          frame, e.getMessage(), "Input/Output Exception", JOptionPane.ERROR_MESSAGE);
      frame.repaint();
      return;
    }
    echo("Connected to opponent!");

    tConn = new Thread(oConn, "conn");
    tConn.start();
    tMain = new Thread(this, "main");
    tMain.start();
  }
Example #2
1
  private void SendText() {
    toNumber = toNumber.replace("-", "");
    toNumber = toNumber.replace("(", "");
    toNumber = toNumber.replace(")", "");
    toNumber = toNumber.replace(" ", "");
    if (!isNumeric(toNumber) || toNumber.length() < 7) {
      setTextStatus(STATUS_NOT_VALID_PHONE_NUMBER);
    }

    try {
      if (textStatus == STATUS_NOT_SENT) {
        Voice voice = new Voice(username, password);

        voice.sendSMS(
            toNumber,
            kioskSettings
                    .getLocaleSettings()
                    .getLocaleString("SaveScreen", "TextMessageToSend", "Prompt")
                + " "
                + getTinyUrl(pageUrl));
        setTextStatus(STATUS_SENT);
      }
    } catch (IOException e) {
      e.printStackTrace();
      new ErrorLog(true, true, "Was unable to send text message.", 0x16);
      setTextStatus(STATUS_IO_EXCEPTION);
      kioskSettings
          .getKioskStatusModule()
          .setKioskStatus("I/O Exception when trying to text customer.", true);
    }
  }
  public boolean showChapitreAddDialog(Chapitre chapitre, int id) {
    try {
      // Load the fxml file and create a new stage for the popup dialog.
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(MainApp.class.getResource("/fxml/addChapitre.fxml"));
      AnchorPane page = (AnchorPane) loader.load();

      // Create the dialog Stage.
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Ajouter un Cours");
      dialogStage.initModality(Modality.APPLICATION_MODAL);
      dialogStage.initStyle(StageStyle.UTILITY);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set the cours into the controller.
      AddChapitreController controller = loader.getController();
      controller.setDialogStage(dialogStage);
      controller.setChapitre(chapitre, id);

      // Show the dialog and wait until the user closes it
      dialogStage.showAndWait();

      return controller.isOkClicked();
    } catch (IOException e) {
      e.printStackTrace();
      return false;
    }
  }
Example #4
1
  public static void saveImageToDisk(
      InputStream inputStream, String fileOriginalName, String fileSaveName, String savePath) {
    int read = 0;
    byte[] bytes = new byte[1024];
    OutputStream out = null;

    try {
      String extension = getExtension(fileOriginalName);
      out = new FileOutputStream(new File(savePath, fileSaveName + "." + extension));

      while ((read = inputStream.read(bytes)) != -1) {
        out.write(bytes, 0, read);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        inputStream.close();
        out.flush();
        out.close();

        // Chama o garbage collector para remover a img temporaria
        System.gc();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
    /**
     * Called for an incoming message.
     *
     * @param inMessage
     */
    public void onMessage(Message inMessage) {
      // disposable exchange, swapped with real Exchange on correlation
      inMessage.setExchange(new ExchangeImpl());
      inMessage.getExchange().put(Bus.class, bus);
      inMessage.put(Message.DECOUPLED_CHANNEL_MESSAGE, Boolean.TRUE);
      inMessage.put(Message.RESPONSE_CODE, HttpURLConnection.HTTP_OK);

      // remove server-specific properties
      // inMessage.remove(AbstractHTTPDestination.HTTP_REQUEST);
      // inMessage.remove(AbstractHTTPDestination.HTTP_RESPONSE);
      inMessage.remove(Message.ASYNC_POST_RESPONSE_DISPATCH);
      updateResponseCode(inMessage);

      // cache this inputstream since it's defer to use in case of async
      try {
        InputStream in = inMessage.getContent(InputStream.class);
        if (in != null) {
          CachedOutputStream cos = new CachedOutputStream();
          IOUtils.copy(in, cos);
          inMessage.setContent(InputStream.class, cos.getInputStream());
        }
        observer.onMessage(inMessage);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
Example #6
1
    @Override
    protected String doInBackground(String... params) {

      byte[] result = null;
      String str = "";

      HttpClient client = new DefaultHttpClient();
      //            HttpGet request = new
      // HttpGet("https://backfinecar-renatdk.c9.io/api/Cars"+mSettings.getString(APP_PREFERENCES_TOKENID,"tokenId"));
      HttpGet request = new HttpGet("https://backfinecar-renatdk.c9.io/api/Cars");

      HttpResponse response;

      try {
        response = client.execute(request);
        result = EntityUtils.toByteArray(response.getEntity());
        str = new String(result, "UTF-8");
        Log.d("Response of GET request", response.toString());
      } catch (ClientProtocolException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }

      return str;
    }
Example #7
1
 private static void init() throws IOException {
   startComponentMethods = new HashMap<String, Set<String>>();
   subSignatures = new HashSet<String>();
   FileReader fr = null;
   BufferedReader br = null;
   String line = null;
   try {
     fr = new FileReader(IPC_FILE);
     br = new BufferedReader(fr);
     while ((line = br.readLine()) != null) {
       String[] tokens = line.split(":");
       String className = tokens[0].substring(1);
       String subSignature = tokens[1].substring(1, tokens[1].length() - 1);
       Set<String> methods = startComponentMethods.get(className);
       if (methods == null) {
         methods = new HashSet<String>();
         methods.add(subSignature);
         subSignatures.add(subSignature);
         startComponentMethods.put(className, methods);
       } else {
         methods.add(subSignature);
         subSignatures.add(subSignature);
       }
     }
   } catch (IOException ioe) {
     System.out.print(ioe.toString());
   } finally {
     if (br != null) br.close();
     if (fr != null) fr.close();
   }
 }
Example #8
1
  public static void coding(String resource, String target) {
    BufferedReader reader = null;
    PrintWriter writer = null;
    try {
      FileInputStream in = new FileInputStream(resource);

      reader = new BufferedReader(new InputStreamReader(in, "GBK"));
      writer = new PrintWriter(target, "UTF-8");
      String line = null;
      while ((line = reader.readLine()) != null) {
        writer.println(line);
      }
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      writer.close();
      if (reader != null) {
        try {
          reader.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
 /**
  * 修改页面提交表单 action="system/choicenesscontent/save"
  *
  * @param yc
  * @param m
  * @return
  * @throws IOException
  */
 @RequestMapping("/save")
 public String save(YztChoicenesscontent yc, ModelMap m, HttpServletRequest request) {
   Json json = new Json();
   int flag = 0;
   // 修改之前先判断是否
   String introduction = yc.getIntroduction();
   if (CommonUtil.notEmpty(yc.getId())) {
     // 不为空的时候是修改
     yc.setModfiytime(new Date());
     // 写入流
     try {
       saveHtmlUrl(request, yc);
     } catch (IOException e) {
       e.printStackTrace();
     }
     flag = choicenesscontentService.updateNotNull(yc);
   } else {
     // 为空的时候添加
     try {
       saveHtmlUrl(request, yc);
     } catch (IOException e) {
       e.printStackTrace();
     }
     yc.setId(GUIDGener.getGUID());
     yc.setCreatetime(new Date());
     yc.setPicCount(0);
     yc.setViewCount(1);
     flag = choicenesscontentService.save(yc);
   }
   return "redirect:view/" + yc.getId();
 }
Example #10
0
  public void initEJB() {
    try {
      InputStream inputStream =
          this.getClass()
              .getClassLoader()
              .getResourceAsStream("hu/neuron/java/sales/services/Settings.properties");

      Properties properties = new Properties();

      try {
        properties.load(inputStream);
      } catch (IOException e) {
        e.printStackTrace();
      }

      Hashtable<String, String> env = new Hashtable<String, String>();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
      env.put(Context.SECURITY_PRINCIPAL, properties.getProperty("SECURITY_PRINCIPAL"));
      env.put(Context.SECURITY_CREDENTIALS, properties.getProperty("SECURITY_CREDENTIALS"));
      env.put(Context.PROVIDER_URL, properties.getProperty("PROVIDER_URL"));
      Context ctx;

      ctx = new InitialContext(env);
      System.out.println("ctx  = " + ctx);
      offerService =
          (OfferServiceRemote)
              ctx.lookup("OfferService#hu.neuron.java.sales.service.OfferServiceRemote");
    } catch (NamingException e) {
      e.printStackTrace();
    }
  }
  protected void addOrUpdateProjectToConf(EditorProject editorProject, IProject gemocProject) {
    IFile configFile = gemocProject.getFile(new Path(Activator.GEMOC_PROJECT_CONFIGURATION_FILE));
    if (configFile.exists()) {
      Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
      Map<String, Object> m = reg.getExtensionToFactoryMap();
      m.put(Activator.GEMOC_PROJECT_CONFIGURATION_FILE_EXTENSION, new XMIResourceFactoryImpl());

      // Obtain a new resource set
      ResourceSet resSet = new ResourceSetImpl();

      // get the resource
      Resource resource =
          resSet.getResource(URI.createURI(configFile.getLocationURI().toString()), true);

      LanguageDefinition gemocLanguageWorkbenchConfiguration =
          (LanguageDefinition) resource.getContents().get(0);
      addOrUpdateProjectToConf(editorProject, gemocLanguageWorkbenchConfiguration);

      try {
        resource.save(null);
      } catch (IOException e) {
        Activator.error(e.getMessage(), e);
      }
    }
    try {
      configFile.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
    } catch (CoreException e) {
      Activator.error(e.getMessage(), e);
    }
  }
Example #12
0
  /*
   * (non-Javadoc)
   *
   * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
   *      javax.faces.component.UIComponent)
   */
  public void apply(FaceletContext ctxObj, UIComponent parent) throws IOException {
    FaceletContextImplBase ctx = (FaceletContextImplBase) ctxObj;
    VariableMapper orig = ctx.getVariableMapper();
    if (this.params != null) {
      VariableMapper vm = new VariableMapperWrapper(orig);
      ctx.setVariableMapper(vm);
      for (int i = 0; i < this.params.length; i++) {
        this.params[i].apply(ctx, parent);
      }
    }

    ctx.pushClient(this);
    String path = null;
    try {
      path = this.template.getValue(ctx);
      ctx.includeFacelet(parent, path);
    } catch (IOException e) {
      if (log.isLoggable(Level.FINE)) {
        log.log(Level.FINE, e.toString(), e);
      }
      throw new TagAttributeException(this.tag, this.template, "Invalid path : " + path);
    } finally {
      ctx.setVariableMapper(orig);
      ctx.popClient(this);
    }
  }
 /**
  * compare the byte-array representation of two TaskObjects.
  *
  * @param f TaskObject
  * @param s TaskObject
  * @return true if the two arguments have the same byte-array
  */
 private boolean sameBytes(TaskObject f, TaskObject s) {
   ByteArrayOutputStream bos = new ByteArrayOutputStream();
   ObjectOutput out = null;
   try {
     out = new ObjectOutputStream(bos);
     out.writeObject(f);
     byte[] fs = bos.toByteArray();
     out.writeObject(s);
     byte[] ss = bos.toByteArray();
     if (fs.length != ss.length) return false;
     for (int i = 0; i < fs.length; i++) {
       if (fs[i] != ss[i]) return false;
     }
     return true;
   } catch (IOException e) {
     e.printStackTrace();
     return false;
   } finally {
     if (out != null) {
       try {
         out.close();
       } catch (IOException e) {
         // ignore
       }
       try {
         bos.close();
       } catch (IOException e) {
         // ignore
       }
     }
   }
 }
Example #14
0
 private void loadImages() {
   try {
     warningIcon = ImageIO.read(getClass().getResource("images/dialog-warning.png"));
   } catch (IOException ex) {
     ex.printStackTrace();
   }
 }
Example #15
0
  public boolean showPersonEditDialog(Person person) {
    try {
      // Load the fxml file and create a new stage for the popup dialog.
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(MainApp.class.getResource("view/PersonEditDialog.fxml"));
      AnchorPane page = (AnchorPane) loader.load();

      // Create the dialog Stage.
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Edit Person");
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set the person into the controller.
      PersonEditDialogController controller = loader.getController();
      controller.setDialogStage(dialogStage);
      controller.setPerson(person);

      // Show the dialog and wait until the user closes it
      dialogStage.showAndWait();

      return controller.isOkClicked();
    } catch (IOException e) {
      e.printStackTrace();
      return false;
    }
  }
  private ByteList doReceive(ThreadContext context, int length) {
    Ruby runtime = context.runtime;
    ByteBuffer buf = ByteBuffer.allocate(length);

    try {
      context.getThread().beforeBlockingCall();

      int read = openFile.getMainStreamSafe().getDescriptor().read(buf);

      if (read == 0) return null;

      return new ByteList(buf.array(), 0, buf.position());

    } catch (BadDescriptorException e) {
      throw runtime.newIOError("bad descriptor");

    } catch (IOException e) {
      // All errors to sysread should be SystemCallErrors, but on a closed stream
      // Ruby returns an IOError.  Java throws same exception for all errors so
      // we resort to this hack...
      if ("Socket not open".equals(e.getMessage())) {
        throw runtime.newIOError(e.getMessage());
      }

      throw runtime.newSystemCallError(e.getMessage());

    } finally {
      context.getThread().afterBlockingCall();
    }
  }
Example #17
0
 /**
  * 从文件读取json字符串
  *
  * @param path 目录
  * @param name 文件名称
  * @return 返回字符串
  */
 public static String readJsonFromFile(String path, String name) {
   if (StringUtils.isEmpty(path) || StringUtils.isEmpty(name)) {
     return null;
   }
   String content = "";
   File file = new File(path + name);
   if (!file.exists()) {
     return null;
   }
   InputStream in = null;
   try {
     in = new FileInputStream(file);
     if (in != null) {
       InputStreamReader inputreader = new InputStreamReader(in);
       BufferedReader buffreader = new BufferedReader(inputreader);
       String line;
       // 分行读取
       while ((line = buffreader.readLine()) != null) {
         content += line;
       }
       in.close();
     }
   } catch (IOException e) {
     e.printStackTrace();
     return null;
   }
   return content;
 }
    @Override
    protected Bitmap doInBackground(String... urls) {

      try {
        URL url = new URL(urls[0]);

        HttpURLConnection connection = (HttpURLConnection) url.openConnection();

        // download then convert
        connection.connect();

        InputStream inputStream = connection.getInputStream();

        Bitmap myBitmap = BitmapFactory.decodeStream(inputStream);

        return myBitmap;

      } catch (MalformedURLException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }

      return null;
    }
 public static void run() {
   MybatisOperation.instance().createTable();
   List<String> warnings = new ArrayList<String>();
   boolean overwrite = true;
   String genCfg = "/generator.xml"; // src的一级目录下
   File configFile = new File(MyBatisGeneratorTool.class.getResource(genCfg).getFile());
   ConfigurationParser cp = new ConfigurationParser(warnings);
   Configuration config = null;
   try {
     config = cp.parseConfiguration(configFile);
   } catch (IOException e) {
     e.printStackTrace();
   } catch (XMLParserException e) {
     e.printStackTrace();
   }
   DefaultShellCallback callback = new DefaultShellCallback(overwrite);
   MyBatisGenerator myBatisGenerator = null;
   try {
     myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
   } catch (InvalidConfigurationException e) {
     e.printStackTrace();
   }
   try {
     myBatisGenerator.generate(null);
   } catch (SQLException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
 }
  /**
   * Uses the command line arguments to authenticate the GoogleService and build the basic feed URI,
   * then invokes all the other methods to demonstrate how to interface with the Translator toolkit
   * service.
   *
   * @param args See the usage method.
   */
  public static void main(String[] args) {
    try {
      // Connect to the Google translator toolkit service
      GttService service = new GttService("sample.gtt.GttClient");

      // Login if there is a command line argument for it.
      if (args.length >= 1 && NAME_TO_COMMAND_MAP.get(args[0]) == GttCommand.LOGIN) {
        GttCommand.LOGIN.execute(service, args);
      }

      // Input stream to get user input
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

      // Do some actions based on user input
      while (true) {
        // Get user input
        System.out.print(USER_PROMPT);
        System.out.flush();
        String userInput = in.readLine();
        System.out.println();

        // Do action corresponding to user input
        String[] commandArgs = userInput.split("\\s+");
        GttCommand command = NAME_TO_COMMAND_MAP.get(commandArgs[0]);
        if (command != null) {
          command.execute(service, commandArgs);
        } else {
          System.out.println("Sorry I did not understand that.");
        }
      }
    } catch (IOException ioe) {
      ioe.printStackTrace();
    }
  }
  @Override
  public ArrayList<Datum> readOneTuple() {
    if (buffer == null) return null;
    String line = null;

    try {
      line = buffer.readLine();
    } catch (IOException e) {
      //			e.printStackTrace();
      return null;
    }

    if (line == null || line.isEmpty()) {
      try {
        buffer.close();
        return null;
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      return null;
    }

    String col[] = line.split("\\|");
    ArrayList<Datum> tuples = new ArrayList<>();
    for (int counter = 0; counter < col.length; counter++) {
      if (indexMaps.containsKey(counter)) {
        String type = indexMaps.get(counter);
        tuples.add(new Datum(type.toLowerCase(), col[counter]));
      }
    }
    return tuples;
  }
  public Bitmap getBitmapFromSd(String imgFilePath) {

    FileInputStream fis = null;

    try {

      fis = new FileInputStream(new File(imgFilePath)); // 文件输入流

      Bitmap bmp = BitmapFactory.decodeStream(fis);

      return bmp;

    } catch (FileNotFoundException e) {

      e.printStackTrace();

    } finally {

      try {

        if (fis != null) {

          fis.close();
        }

      } catch (IOException e) {

        e.printStackTrace();
      }
    }
    return null;
  }
Example #23
0
 private List<Article> loadNewsFromFile(Context context) {
   startedLoadingNews = true;
   List<Article> articles = new ArrayList<>();
   if (newsFile == null) newsFile = new File(context.getFilesDir(), NEWS_FILE_NAME);
   if (newsFile.exists()) {
     try {
       BufferedReader reader = new BufferedReader(new FileReader(newsFile));
       String currentLine = reader.readLine();
       if (currentLine != null) {
         String[] split = currentLine.split("-");
         if (split.length > 1) {
           for (int i = 0;
               i < Integer.parseInt(split[1]);
               i++) { // TODO figure out why all lines, after i = 18, are null.
             currentLine = reader.readLine();
             Article a = readArticle(reader);
             articles.add(a);
             Log.d("q32", "" + i + "line: " + currentLine);
           }
         } else {
           updateNews(context);
         } // if we didn't find the number of articles, the file must be corrupt. Update the file.
       } else updateNews(context);
     } catch (IOException e) {
       Log.d("Unit5Calendar", e.getMessage(), e);
     }
     Collections.sort(newsArticles, Utils.articlePubDateSorter);
     newsReady = true;
   }
   return articles;
 }
  /**
   * Gets the token.
   *
   * @param scope the scope
   * @return the token
   */
  private String getToken(String scope) {
    Process curlProc;
    String outputString;
    DataInputStream curlIn = null;
    String access_token = null;
    String command =
        "curl -X POST -H Content-Type:application/x-www-form-urlencoded "
            + adminUrl
            + "/oauth2/token --insecure --data"
            + " client_id="
            + client_id
            + "&"
            + "client_secret="
            + client_secret
            + "&grant_type=client_credentials&scope="
            + scope;
    try {
      curlProc = Runtime.getRuntime().exec(command);

      curlIn = new DataInputStream(curlProc.getInputStream());

      while ((outputString = curlIn.readLine()) != null) {
        JSONObject obj = new JSONObject(outputString);
        access_token = obj.getString("access_token");
      }
    } catch (IOException e1) {
      e1.printStackTrace();
    } catch (JSONException e) {
      e.printStackTrace();
    }
    return access_token;
  }
Example #25
0
  /** @param args the command line arguments */
  public static void main(String[] args) {
    File excelFile =
        new File("/home/the_fegati/Dropbox/project/data/100-Patients/LabsCorePopulatedTable.xlsx");
    ExcelReader excelReader = new ExcelReader(excelFile);
    // ArrayList<ArrayList<Object>> list = excelReader.getRowAsListFromExcel();

    /*instantiate class DataExport and pass the arraylist data to be exported
    to database*/
    DataExport dataExport = new DataExport();
    // dataExport.tblPatientDetailsExport(list);
    // dataExport.tblICD10Export(list);
    // dataExport.tblAdmissionsExport(list);
    // dataExport.tblAdmissionDiagnosesExport(list);
    // dataExport.tblLabsExport(list);

    Fuzzification f = new Fuzzification();
    // f.getLabsData();

    DataConnection dataConnection = new DataConnection();
    PrintWriter out = new PrintWriter(System.out, true);
    //        dataConnection.dataConnect(out, minSupport, minConfidence);

    String filename = "tblFuzzyLabs.csv";
    Double minSupport = 0.7;
    Double minConfidence = 0.8;
    DataHelper.init(minSupport, minConfidence);
    Apriori aprioriHelper = new Apriori();

    try {
      aprioriHelper.doApriori(minSupport, minConfidence, filename);
    } catch (IOException e) {
      System.err.println("I/O failed " + e.toString());
    }
  }
Example #26
0
 // convert bitmap to base64
 public static String bitmapToBase64(Bitmap bitmap) {
   String result = null;
   ByteArrayOutputStream baos = null;
   try {
     if (bitmap != null) {
       baos = new ByteArrayOutputStream();
       bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
       baos.flush();
       baos.close();
       byte[] bitmapBytes = baos.toByteArray();
       result = Base64.encodeToString(bitmapBytes, Base64.DEFAULT);
     }
   } catch (IOException e) {
     e.printStackTrace();
   } finally {
     try {
       if (baos != null) {
         baos.flush();
         baos.close();
       }
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
   return result;
 }
  private void showObjectifDialog(int id) {
    try {
      // Load the fxml file and create a new stage for the popup dialog.
      System.out.println("hello");
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(MainApp.class.getResource("/fxml/displayObjectif.fxml"));
      AnchorPane page = (AnchorPane) loader.load();

      // Create the dialog Stage.
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Objectif");
      dialogStage.initModality(Modality.APPLICATION_MODAL);
      dialogStage.initStyle(StageStyle.UTILITY);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set the cours into the controller.
      DisplayObjectifController control = loader.getController();
      control.setDialogStage(dialogStage);
      control.setObjectif(id);

      // Show the dialog and wait until the user closes it
      dialogStage.showAndWait();

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Example #28
0
 /** @param b byte[] */
 public void appendBody(final byte[] b) {
   try {
     this.body.write(b);
   } catch (IOException ex) {
     ex.printStackTrace();
   }
 }
Example #29
0
  @Override
  public void run() throws SRMException, IllegalStateTransition {
    if (!getState().isFinal() && !isProcessingDone()) {
      try {
        proccessRequest();
        boolean hasOnlyFinalFileRequests = true;
        for (CopyFileRequest request : getFileRequests()) {
          State state = request.getState();
          if (!state.isFinal()) {
            hasOnlyFinalFileRequests = false;
          }
        }

        setProcessingDone(true);
        if (hasOnlyFinalFileRequests) {
          setState(State.DONE, "All transfers completed.");
        } else {
          addHistoryEvent("Waiting for transfers to complete.");
        }
      } catch (IOException e) {
        throw new SRMException(e.getMessage(), e);
      } catch (InterruptedException e) {
        throw new SRMException("shutting down.", e);
      }
    }
  }
  private void writeAudioDataToFile() {
    byte data[] = new byte[bufferSize];
    String filename = getTempFilename();
    FileOutputStream os = null;

    try {
      os = new FileOutputStream(filename);
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      Log.d("SAN", e.getMessage());
    }

    int read = 0;

    if (null != os) {
      while (isRecording) {
        read = recorder.read(data, 0, bufferSize);

        if (AudioRecord.ERROR_INVALID_OPERATION != read) {
          try {
            os.write(data);
          } catch (IOException e) {
            Log.d("SAN", e.getMessage());
          }
        }
      }

      try {
        os.close();
      } catch (IOException e) {
        Log.d("SAN", e.getMessage());
      }
    }
  }