ai cho em hỏi sao em ghi dữ liệu ra file text rồi, nhưng khi em kiểm tra lại file text thì thấy dữ liệu không đúng, như kiểu bị mã hóa hết vậy?

  • nội dung file input.txt để đọc của em là: Nguyễn Văn Q,21,100000.0 NGuyễn Thị B,20,200000.0
  • nhưng khi đọc và xuất sang file output.txt thì nó lại thế này: [Ljava.lang.String;@55f96302 [I@3d4eac69 [D@42a57993 [Ljava.lang.String;@55f96302 [I@3d4eac69 [D@42a57993
  • Đây là code của em ạ :

    import java.io.*;
    import java.util.*;
    
    class input_file
    {
          String ten[]=new String[100];
          int tuoi[]= new int[100];
          double luong[]= new double[100];
          int i=0;
          static Scanner scn =new Scanner(System.in)
     void read() throws IOException{
        String line[] = new String[100];
        FileInputStream f=new FileInputStream("input.txt");
        Scanner input= new Scanner(f,"UTF-8");
    
        while (input.hasNextLine()) 
        {
            line[i]=input.nextLine();
            if (line[i].trim()!=""){
                String item[] = line[i].split(",");
                ten[i]=item[0]; 
                tuoi[i]=Integer.parseInt(item[1]);
                luong[i]=Double.parseDouble(item[2]);
            }
            i++;
        }
        input.close();  
    }
    }
    public class NhapXuat {
    public static void main(String[] args) throws IOException {
        input_file file= new input_file();
        file.read();
        file.write();
    }
    }

Viết câu trả lời

Drop Images

0 Bình luận