Ejemplo n.º 1
0
 @FXML
 private void handleExportItemAction(ActionEvent event) {
   try {
     BufferedWriter bw =
         new BufferedWriter(
             new OutputStreamWriter(new FileOutputStream("imageInformation.csv"), "UTF-8"));
     for (ImageInformation img : imgMan.images) {
       StringBuffer oneLine = new StringBuffer();
       oneLine.append(img.getPath());
       oneLine.append(";");
       for (Point p : img.getPoints()) {
         oneLine.append(p.getX() + "," + p.getY());
       }
       oneLine.append(";");
       for (ImageInformation.Type t : img.getTypes()) {
         oneLine.append(t.toString());
       }
       oneLine.append(";");
       for (double d : img.getFrequency()) {
         oneLine.append(d + ",");
       }
       oneLine.append(";");
       bw.write(oneLine.toString());
       bw.newLine();
     }
     bw.flush();
     bw.close();
   } catch (UnsupportedEncodingException e) {
   } catch (FileNotFoundException e) {
   } catch (IOException e) {
   }
 }
Ejemplo n.º 2
0
  public void write(OutputStream os) throws Exception {
    BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));

    String str = toString();
    bw.write(str, 0, str.length());
    bw.newLine();
    bw.close();
  }
Ejemplo n.º 3
0
 /**
  * sends a raw message
  *
  * @param message is a string with the message
  */
 public void sendRaw(String message) {
   try {
     writer.write(message);
     writer.newLine();
     writer.flush();
   } catch (SocketException e) {
     System.out.println("[Server] Tried to send message to disconnected client.");
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 4
0
  public void ecrireFichier(String chemin, Vector<Integer> highScore) {
    try {
      FileWriter fw = new FileWriter(chemin, false);

      BufferedWriter output = new BufferedWriter(fw);

      for (int i = 0; i < highScore.size(); i++) {
        output.write(highScore.get(i).toString());
        output.newLine();
      }

      output.flush();

      output.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }