DOMANDA Java write e save in un File.txt

Blackware

Nuovo Utente
10
1
Salve a tutti ragazzi. Sto svolgendo questo esercizio per allenarmi un po con Java e WindowBuilder. Putroppo però ho problemi quando tento di salvare i miei 3 INT in un file di testo (Questo servirà perchè poi creero il metodo LOAD)
Apprezzerei davvero molto se qualcuno mi desse delle delucidazioni su quanto segue e dove sono i miei principali errori.
Vi ringrazio

Java:
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Image;
import java.io.*;
import java.lang.*;
import java.util.*;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JButton;
import javax.swing.JDialog;

import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Formatter;

import javax.swing.JTextArea;
import javax.swing.DropMode;
import java.awt.Font;

public class GUI extends JFrame {

    private JPanel contentPane;
    private JTextField textField;
    private JTextField textField_1;
    private JTextField textField_2;
    
    int Win;
    int Kill;
    int Death;
    
    int contWin=0;
    int contKill=0;
    int contDeath=0;
    
    String S_Kill;
    String S_Death;
    String S_Win;
    
    
    //Main

    public static void main(String[] args)
    {
        EventQueue.invokeLater(new Runnable()
        {
            public void run()
            {
                try
                {
                    GUI frame = new GUI();
                    frame.setVisible(true);
                    frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
    
                                                                                        //Creazione File
    
    /*private Formatter x;
    
    public void openFile()
    {
        try
        {
            x = new Formatter("DarwinStats.txt");
        }
        catch(Exception e)
        {
            System.out.println("Errore!");
        }
    }
    
    public void addRecords()
    {   
        x.format("%s%s%s", S_Kill, S_Death , S_Win);
    }
    
    public void closeFile()
    {
        x.close();
    } */
    
                                                                                        //Creazione File Metodo 2
    
    /*public void SaveFile()
    {
        try
        {
            FileWriter writer = new FileWriter("Darwin.txt",true);
            writer.write(S_Kill);
            writer.write(S_Death);
            writer.write(S_Win);
            writer.close();
        }
        catch(Exception e)
        {
            System.out.println("Errore!");
        }
    }*/
    
    
    //GUI

    public GUI() {
        super("Darwin Project Stats Tracker");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 1920, 1080);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        contentPane.setLayout(null);
        setContentPane(contentPane);
        Image Background = new ImageIcon(this.getClass().getResource("/Background.png")).getImage();
        
        Image Layout = new ImageIcon(this.getClass().getResource("/Layout12.png")).getImage();
        
        textField = new JTextField();
        textField.setEditable(false);
        textField.setBounds(463, 480, 381, 38);
        contentPane.add(textField);
        textField.setColumns(10);
        
        textField_1 = new JTextField();
        textField_1.setEditable(false);
        textField_1.setColumns(10);
        textField_1.setBounds(463, 560, 381, 38);
        contentPane.add(textField_1);
        
        textField_2 = new JTextField();
        textField_2.setEditable(false);
        textField_2.setColumns(10);
        textField_2.setBounds(463, 642, 381, 38);
        contentPane.add(textField_2);
        
        JLabel lblNewLabel_9 = new JLabel("");
        lblNewLabel_9.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                
                GUI g = new GUI();
                //  g.SaveFile();             //Metodo 2
                //    g.openFile();            //Metodo 1
                //    g.addRecords();            //Metodo 1
                //    g.closeFile();            //Metodo 1
                
            }
        });
        
        JLabel lblNewLabel_0 = new JLabel("");
        lblNewLabel_0.setForeground(Color.WHITE);
        lblNewLabel_0.setFont(new Font("Microsoft YaHei UI Light", Font.BOLD, 21));
        lblNewLabel_0.setBounds(673, 364, 45, 30);
        contentPane.add(lblNewLabel_0);
        
        JLabel lblNewLabel_1 = new JLabel("");
        lblNewLabel_1.setForeground(Color.WHITE);
        lblNewLabel_1.setFont(new Font("Microsoft YaHei UI Light", Font.BOLD, 21));
        lblNewLabel_1.setBounds(343, 416, 38, 30);
        contentPane.add(lblNewLabel_1);
        lblNewLabel_9.setBounds(614, 691, 293, 71);
        contentPane.add(lblNewLabel_9);
        
        JLabel lblNewLabel_2 = new JLabel("");
        lblNewLabel_2.setForeground(Color.WHITE);
        lblNewLabel_2.setFont(new Font("Microsoft YaHei UI Light", Font.BOLD, 21));
        lblNewLabel_2.setBounds(343, 364, 45, 30);
        contentPane.add(lblNewLabel_2);

        
        JLabel lblNewLabel_8 = new JLabel("");
        lblNewLabel_8.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
            }
        });
        lblNewLabel_8.setBounds(284, 691, 293, 71);
        contentPane.add(lblNewLabel_8);
        
        JLabel lblNewLabel_7 = new JLabel("");
        lblNewLabel_7.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent arg0) {
                Win+=1;
                contWin+=1;
                lblNewLabel_0.setText("x"+contWin);
            }
        });
        lblNewLabel_7.setBounds(614, 344, 293, 71);
        contentPane.add(lblNewLabel_7);
        
        JLabel lblNewLabel_6 = new JLabel("");
        lblNewLabel_6.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                Death+=1;
                contDeath+=1;
                lblNewLabel_1.setText("x"+contDeath);
            }
        });
        lblNewLabel_6.setBounds(284, 395, 293, 71);
        contentPane.add(lblNewLabel_6);
        
        JLabel lblNewLabel_5 = new JLabel("");
        lblNewLabel_5.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e)
            {
                Kill+=1;
                contKill+=1;
                lblNewLabel_2.setText("x"+contKill);
            }
        });
        lblNewLabel_5.setBounds(284, 344, 293, 71);
        contentPane.add(lblNewLabel_5);
        
        JLabel lblNewLabel_3 = new JLabel("");
        lblNewLabel_3.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
            }
        });
        lblNewLabel_3.setBounds(451, 745, 293, 71);
        contentPane.add(lblNewLabel_3);
        
        JLabel lblNewLabel_4 = new JLabel("");
        lblNewLabel_4.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent arg0) {               
                int scelta;
                scelta = JOptionPane.showConfirmDialog(null, "Sei sicuro/a di voler continuare?", "Conferma", JOptionPane.INFORMATION_MESSAGE);
                
                if(scelta == JOptionPane.YES_OPTION)
                {
                    JOptionPane.showMessageDialog(null,"I dati sono stati inseriti correttamente.");
                    S_Kill = Integer.toString(Kill);
                    S_Death = Integer.toString(Death);
                    S_Win = Integer.toString(Win);
                    lblNewLabel_1.setText("");
                    lblNewLabel_2.setText("");
                    lblNewLabel_0.setText("");
                    contKill=0;
                    contDeath=0;
                    contWin=0;
                }
                else if(scelta == JOptionPane.NO_OPTION)
                {
                    JOptionPane.showMessageDialog(null,"Reinserire i dati.");
                    lblNewLabel_1.setText("");
                    lblNewLabel_2.setText("");
                    lblNewLabel_0.setText("");
                    contKill=0;
                    contDeath=0;
                    contWin=0;
                }
            }
        });
        lblNewLabel_4.setBounds(614, 395, 293, 71);
        contentPane.add(lblNewLabel_4);
        JLabel label = new JLabel("");
        label.setBounds(194, 304, 795, 524);
        contentPane.add(label);
        
        label.setIcon(new ImageIcon(Layout));
        
        JLabel lblNewLabel = new JLabel("");
        lblNewLabel.setBackground(Color.WHITE);
        
        lblNewLabel.setBounds(-8, -19, 1920, 1080);
        contentPane.add(lblNewLabel);
        lblNewLabel.setIcon(new ImageIcon(Background));
        
        Image Kill = new ImageIcon(this.getClass().getResource("/Kill1234.png")).getImage();
        lblNewLabel_5.setIcon(new ImageIcon(Kill));
        
        Image Inserisci = new ImageIcon(this.getClass().getResource("/Inserisci123456.png")).getImage();
        lblNewLabel_4.setIcon(new ImageIcon(Inserisci));
        
        Image Visualizza = new ImageIcon(this.getClass().getResource("/Visualizza.png")).getImage();
        lblNewLabel_3.setIcon(new ImageIcon(Visualizza));
        
        Image Death = new ImageIcon(this.getClass().getResource("/Death123.png")).getImage();
        lblNewLabel_6.setIcon(new ImageIcon(Death));
        
        Image Win = new ImageIcon(this.getClass().getResource("/Win.png")).getImage();
        lblNewLabel_7.setIcon(new ImageIcon(Win));
        
        Image Load = new ImageIcon(this.getClass().getResource("/Load.png")).getImage();
        lblNewLabel_8.setIcon(new ImageIcon(Load));
        
        Image Save = new ImageIcon(this.getClass().getResource("/Save.png")).getImage();
        lblNewLabel_9.setIcon(new ImageIcon(Save));
    }
}
 

BitCrafter

Utente Attivo
279
14
CPU
Intel® Core™ i7-4790K (8M Cache, up to 4.40 GHz)
Dissipatore
Noctua NH-D14
Scheda Madre
Gigabyte GA-Z97X-Gaming 5
Hard Disk
SSD: Samsung MZ-7KE256BW SSD 850 PRO | HD: Western Digital WD1003FZEX Caviar Black
RAM
G-Skill TridentX F3-1600C7D-16GTX
Scheda Video
eVGA GeForce GTX 970 ACX 2.0 4096 MB GDDR5
Scheda Audio
Creative SB X-Fi Titanium PCI-e Bulk
Monitor
LG 34GK950F-B UltraGear 34" 21:9 Curved 1ms QHD nIPS HDR 400 FSync2 | SAMSUNG XL2370 23" FHD 2ms
Alimentatore
XFX 1050W Black Edition
Case
Fractal Design Define XL-R2 (Black)
Periferiche
Keyboard: Cooler Master MasterKeys Pro L RGB - Mouse: Logitech Performance MX
Sistema Operativo
Windows 10 Professional X64
Ciao,
ti riporto qui i due metodi per salvare su e caricare da file di testo.
Ti ho lasciato anche le stampe in System.out poi vedrai tu se tenerle oppure no :)

Java:
    void SaveToFile() {
        try {
            FileWriter writer = new FileWriter("text.txt", true);
            BufferedWriter bufferedWriter = new BufferedWriter(writer);

            bufferedWriter.write(S_Kill);
            bufferedWriter.newLine();  // write new line
            bufferedWriter.write(S_Death);
            bufferedWriter.newLine();   // write new line
            bufferedWriter.write(S_Win);

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

    void LoadFromFile() {
        try (FileReader reader = new FileReader("text.txt")) {
            BufferedReader bufferedReader = new BufferedReader(reader);

            S_Kill = bufferedReader.readLine();
            S_Death = bufferedReader.readLine();
            S_Win = bufferedReader.readLine();

            Kill = Integer.parseInt(S_Kill);
            Death = Integer.parseInt(S_Death);
            Win = Integer.parseInt(S_Win);

            System.out.println("Kill -> " + Kill);
            System.out.println("Death -> " + Death);
            System.out.println("Win -> " + Win);

            /*int character;
            while ((character = reader.read()) != -1) {
                System.out.print((char) character);
            }*/
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
Spero che questo risolva il tuo problema.

Ciao!
 
  • Mi piace
Reactions: Blackware

Blackware

Nuovo Utente
10
1
Sono riuscito a creare il save e il load che funzionano perfettamente però c'è ancora un problema. Io voglio tenere conto di solo 3 valori (ovvero le prime tre righe). Per fare ciò ho bisogno di qualcosa per pulire il mio file (Altrimenti ogni volta che si clicca salva i contenuti verranno aggiunti e quindi non sarà possibile leggerli). La cancellazione ovviamente dovrà avvenire quando clicco il bottone SALVA.

L'evento del tasto salva sarà quindi:

1) Prendo i primi 3 valori dal file
2) Cancello il contenuto del file
3) Aggiorno i miei valori
4) Li rimetto nel file

Il problema sorge appunto, come detto prima, sul punto2
Qualche suggerimento?
Vi ringrazio

(Vi lascio qui sotto il codice)
Java:
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Image;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

public class GUI extends JFrame {

    private JPanel contentPane;
    private JTextField textField;
    private JTextField textField_1;
    private JTextField textField_2;
    
    int Win;
    int Kill;
    int Death;
    double K_D;
    
    int contWin=0;
    int contKill=0;
    int contDeath=0;
    
    String S_Nome = "✉PostmanPat✉";
    String S_Rateo;
    String S_Kill;
    String S_Death;
    String S_Win;
    
    
    //Main

    public static void main(String[] args)
    {
        EventQueue.invokeLater(new Runnable()
        {
            public void run()
            {
                try
                {
                    GUI frame = new GUI();
                    frame.setVisible(true);
                    frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
    
    public void SaveToFile() {
        
        try {
            JOptionPane.showMessageDialog(null,"I dati sono stati inseriti correttamente.");
            FileWriter writer = new FileWriter("DarwinProject.txt", true);
            BufferedWriter bufferedWriter = new BufferedWriter(writer);
            
            String temp_Kill;
            String temp_Death;
            String temp_Win;
            
            FileReader reader = new FileReader("DarwinProject.txt");
            BufferedReader bufferedReader = new BufferedReader(reader);
            
            temp_Kill = bufferedReader.readLine();
            temp_Death = bufferedReader.readLine();
            temp_Win = bufferedReader.readLine();
            
            
            
            int x = Integer.parseInt(temp_Kill);
            int y = Integer.parseInt(temp_Death);
            int z = Integer.parseInt(temp_Win);
            
            x = x+Kill;
            y = y+Death;
            z = z+Win;
            
            S_Kill = Integer.toString(x);
            S_Death = Integer.toString(y);
            S_Win = Integer.toString(z);
            
            bufferedWriter.write(S_Kill);
            bufferedWriter.newLine();  // scrive una nuova linea
            bufferedWriter.write(S_Death);
            bufferedWriter.newLine();   // scrive una nuova linea
            bufferedWriter.write(S_Win);
            bufferedWriter.newLine();

            bufferedWriter.close();
            
        } catch (IOException e)
        {
            e.printStackTrace();
        }
    }
    
    public void K_D_Rateo(String a, String b)
    {   
        Double t1 = Double.parseDouble(a);
        Double t2 = Double.parseDouble(b);
        
        K_D = (t1+t2)/2;                    // Kill Death rateo
        
        S_Rateo = Double.toString(K_D);
    }

    public void LoadFromFile()
    {
        try (FileReader reader = new FileReader("DarwinProject.txt"))
        {
            BufferedReader bufferedReader = new BufferedReader(reader);

            String a = bufferedReader.readLine();
            String b = bufferedReader.readLine();
            String c = bufferedReader.readLine();
          
            
            K_D_Rateo(a,b);
            
            textField.setText(S_Nome);
            textField_1.setText(S_Rateo);
            textField_2.setText(c);
            
        } catch (IOException e)
        {
            e.printStackTrace();
        }
    }
    
    
    //GUI

    public GUI() {
        super("Darwin Project Stats Tracker");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 1920, 1080);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        contentPane.setLayout(null);
        setContentPane(contentPane);
        Image Background = new ImageIcon(this.getClass().getResource("/Background.png")).getImage();
        
        Image Layout = new ImageIcon(this.getClass().getResource("/Layout12.png")).getImage();
        
        textField = new JTextField();
        textField.setEditable(false);
        textField.setBounds(463, 480, 381, 38);
        contentPane.add(textField);
        textField.setColumns(10);
        
        textField_1 = new JTextField();
        textField_1.setEditable(false);
        textField_1.setColumns(10);
        textField_1.setBounds(463, 560, 381, 38);
        contentPane.add(textField_1);
        
        textField_2 = new JTextField();
        textField_2.setEditable(false);
        textField_2.setColumns(10);
        textField_2.setBounds(463, 642, 381, 38);
        contentPane.add(textField_2);
        
        JLabel lblNewLabel_0 = new JLabel("");
        lblNewLabel_0.setForeground(Color.WHITE);
        lblNewLabel_0.setFont(new Font("Microsoft YaHei UI Light", Font.BOLD, 21));
        lblNewLabel_0.setBounds(673, 364, 45, 30);
        contentPane.add(lblNewLabel_0);
        
        JLabel lblNewLabel_1 = new JLabel("");
        lblNewLabel_1.setForeground(Color.WHITE);
        lblNewLabel_1.setFont(new Font("Microsoft YaHei UI Light", Font.BOLD, 21));
        lblNewLabel_1.setBounds(343, 416, 38, 30);
        contentPane.add(lblNewLabel_1);
        
        JLabel lblNewLabel_2 = new JLabel("");
        lblNewLabel_2.setForeground(Color.WHITE);
        lblNewLabel_2.setFont(new Font("Microsoft YaHei UI Light", Font.BOLD, 21));
        lblNewLabel_2.setBounds(343, 364, 45, 30);
        contentPane.add(lblNewLabel_2);
        
        JLabel lblNewLabel_9 = new JLabel("");
        lblNewLabel_9.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e)
            {   
                
                SaveToFile();
                lblNewLabel_1.setText("");
                lblNewLabel_2.setText("");
                lblNewLabel_0.setText("");
                
                
            }
        });
        
        lblNewLabel_9.setBounds(614, 691, 293, 71);
        contentPane.add(lblNewLabel_9);

        
        JLabel lblNewLabel_8 = new JLabel("");
        lblNewLabel_8.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                LoadFromFile();
                
            }
        });
        lblNewLabel_8.setBounds(284, 691, 293, 71);
        contentPane.add(lblNewLabel_8);
        
        JLabel lblNewLabel_7 = new JLabel("");
        lblNewLabel_7.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent arg0) {
                Win+=1;
                contWin+=1;
                lblNewLabel_0.setText("x"+contWin);
            }
        });
        lblNewLabel_7.setBounds(614, 344, 293, 71);
        contentPane.add(lblNewLabel_7);
        
        JLabel lblNewLabel_6 = new JLabel("");
        lblNewLabel_6.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                Death+=1;
                contDeath+=1;
                lblNewLabel_1.setText("x"+contDeath);
            }
        });
        lblNewLabel_6.setBounds(284, 395, 293, 71);
        contentPane.add(lblNewLabel_6);
        
        JLabel lblNewLabel_5 = new JLabel("");
        lblNewLabel_5.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e)
            {
                Kill+=1;
                contKill+=1;
                lblNewLabel_2.setText("x"+contKill);
            }
        });
        lblNewLabel_5.setBounds(284, 344, 293, 71);
        contentPane.add(lblNewLabel_5);
        
        JLabel lblNewLabel_3 = new JLabel("");
        lblNewLabel_3.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
            }
        });
        lblNewLabel_3.setBounds(451, 745, 293, 71);
        contentPane.add(lblNewLabel_3);
        
        JLabel lblNewLabel_4 = new JLabel("");
        lblNewLabel_4.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent arg0) {               
                int scelta;
                scelta = JOptionPane.showConfirmDialog(null, "Sei sicuro/a di voler continuare?", "Conferma", JOptionPane.INFORMATION_MESSAGE);
                
                if(scelta == JOptionPane.YES_OPTION)
                {
                    contKill=0;
                    contDeath=0;
                    contWin=0;
                }
                else if(scelta == JOptionPane.NO_OPTION)
                {
                    JOptionPane.showMessageDialog(null,"Reinserire i dati.");
                    lblNewLabel_1.setText("");
                    lblNewLabel_2.setText("");
                    lblNewLabel_0.setText("");
                    contKill=0;
                    contDeath=0;
                    contWin=0;
                }
            }
        });
        lblNewLabel_4.setBounds(614, 395, 293, 71);
        contentPane.add(lblNewLabel_4);
        JLabel label = new JLabel("");
        label.setBounds(194, 304, 795, 524);
        contentPane.add(label);
        
        label.setIcon(new ImageIcon(Layout));
        
        JLabel lblNewLabel = new JLabel("");
        lblNewLabel.setBackground(Color.WHITE);
        
        lblNewLabel.setBounds(-8, -19, 1920, 1080);
        contentPane.add(lblNewLabel);
        lblNewLabel.setIcon(new ImageIcon(Background));
        
        Image Kill = new ImageIcon(this.getClass().getResource("/Kill1234.png")).getImage();
        lblNewLabel_5.setIcon(new ImageIcon(Kill));
        
        Image Inserisci = new ImageIcon(this.getClass().getResource("/Inserisci123456.png")).getImage();
        lblNewLabel_4.setIcon(new ImageIcon(Inserisci));
        
        Image Visualizza = new ImageIcon(this.getClass().getResource("/Visualizza.png")).getImage();
        lblNewLabel_3.setIcon(new ImageIcon(Visualizza));
        
        Image Death = new ImageIcon(this.getClass().getResource("/Death123.png")).getImage();
        lblNewLabel_6.setIcon(new ImageIcon(Death));
        
        Image Win = new ImageIcon(this.getClass().getResource("/Win.png")).getImage();
        lblNewLabel_7.setIcon(new ImageIcon(Win));
        
        Image Load = new ImageIcon(this.getClass().getResource("/Load.png")).getImage();
        lblNewLabel_8.setIcon(new ImageIcon(Load));
        
        Image Save = new ImageIcon(this.getClass().getResource("/Save.png")).getImage();
        lblNewLabel_9.setIcon(new ImageIcon(Save));
    }
}
 

BAT00cent

Utente Attivo
1,351
655
nel metodo di salvataggio SaveTofile (che dovrebbe chiamarsi saveToFile con la "s" minuscola) aggiungi un parametro booleano "append" che poi passerai al costruttore FileWiter, ossia
saveTofile(boolean append)
e all'interno la chiamata
FileWriter writer = new FileWriter("text.txt", append);
quando append=true aggiungi a fine file, quando è false sovrascrive il file precedente;
se invece devi solo sovrascrivere non c'è bisogno di aggiungere un parametro ma devi modificare il costruttore passandogli direttamente false (invece che true come ora)
 
Ultima modifica:

Blackware

Nuovo Utente
10
1
Ha funzionato! Dovevo solo sovrascriverle le variabili e il tutto è andato come dovrebbe. Devo solo sistemare dei miei errori e ho fatto

tipo:
Primo inserimento(Nel file direttamente): 0-0-0
Secondo inserimento: 1-1-1 {VISUALIZZAZIONE CORRETTA}
Terzo inserimento: 3-3-3 {VISUALIZZAZIONE: 5-5-5 e invece dovrebbe dare 4-4-4 facendo 3+1 / 3+1 / 3+1}
Post automaticamente unito:

Grazie mille ;)
 
Ultima modifica:

Entra

oppure Accedi utilizzando

Discussioni Simili

Hot del momento