안녕하세요. 자바fx 과제 하는중 질문있습니다.(

조회수 728회

서버에서 받아오는 메시지를 Split으로 잘라 배열로 만든다음 배열 하나씩 Tableview 행에 넣는거 까지는 완성했습니다. 그리고나서 2번째행부터 그 후 오는 메시지를 행으로 표현할려고 for문을 사용해 봤으나 "For input string" 오류가 나네요 ㅠㅠ

메시지를 배열로 수신하여 여러 줄의 테이블 뷰에 추가하는 방법을 알수있을까요?

public void RPserch(ActionEvent event) throws Exception {
    //중략//
            in = cltSocket.getInputStream();
            String strRcvMsg = "";
            int nRcvLen = in.read(byteRBuff);
            strRcvMsg = new String(byteRBuff, 0, nRcvLen, "EUC-KR");
            Thread.sleep(500);
            System.out.println(strRcvMsg);
            String[] testmsg = strRcvMsg.split("&");
            System.out.println(testmsg[1]);
            int r = Integer.parseInt(testmsg[1]);
            int j = 2;

            ObservableList<Person> data = FXCollections.<Person>observableArrayList();
            for (int k = 2; k < r; j++) {
                data.add(new Person("", testmsg[j], testmsg[j + 1], testmsg[j + 2], testmsg[j + 3], testmsg[j + 4],testmsg[j + 5], testmsg[j + 6], testmsg[j + 7], testmsg[j + 8]));
                j += 9;
            }
            remark.setCellValueFactory(cellData -> cellData.getValue().remarkProperty());
            Purchplan.setCellValueFactory(cellData -> cellData.getValue().PurchplanProperty());
            Producplan.setCellValueFactory(cellData -> cellData.getValue().ProducplanProperty());
            itemname.setCellValueFactory(cellData -> cellData.getValue().itemnameProperty());
            RPamount.setCellValueFactory(cellData -> cellData.getValue().RPamountProperty());
            RPdate.setCellValueFactory(cellData -> cellData.getValue().RPdateProperty());
            RPlocation.setCellValueFactory(cellData -> cellData.getValue().RPlocationProperty());
            RPperson.setCellValueFactory(cellData -> cellData.getValue().RPpersonProperty());
            buyer.setCellValueFactory(cellData -> cellData.getValue().buyerProperty());
            condition.setCellValueFactory(cellData -> cellData.getValue().conditionProperty());
            RPTableview.setItems(data);

        } catch (Exception e) {
            System.out.println("[EXP] Tableview " + e.getLocalizedMessage());
        }
    }

클래스입니다.

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

public class Person {
    public SimpleStringProperty Purchplan;
    public SimpleStringProperty Producplan;
    public SimpleStringProperty itemname;
    public SimpleStringProperty RPamount;
    public SimpleStringProperty RPdate;
    public SimpleStringProperty RPlocation;
    public SimpleStringProperty RPperson;
    public SimpleStringProperty buyer;
    public SimpleStringProperty condition;
    public SimpleStringProperty remark;

    public Person(String remark, String Purchplan, String producplan, String itemname, String RPamount, String RPdate,
            String RPlocation, String RPperson, String buyer, String condition) {
        this.remark = new SimpleStringProperty(remark);
        this.Purchplan = new SimpleStringProperty(Purchplan);
        this.Producplan = new SimpleStringProperty(producplan);
        this.itemname = new SimpleStringProperty(itemname);
        this.RPamount = new SimpleStringProperty(RPamount);
        this.RPdate = new SimpleStringProperty(RPdate);
        this.RPlocation = new SimpleStringProperty(RPlocation);
        this.RPperson = new SimpleStringProperty(RPperson);
        this.buyer = new SimpleStringProperty(buyer);
        this.condition = new SimpleStringProperty(condition);
    }
    // bom 검색

    public StringProperty remarkProperty() {
        return remark;
    }

    public StringProperty PurchplanProperty() {
        return Purchplan;
    }

    public StringProperty ProducplanProperty() {
        return Producplan;
    }

    public StringProperty itemnameProperty() {
        return itemname;
    }

    public StringProperty RPamountProperty() {
        return RPamount;
    }

    public StringProperty RPdateProperty() {
        return RPdate;
    }

    public StringProperty RPlocationProperty() {
        return RPlocation;
    }

    public StringProperty RPpersonProperty() {
        return RPperson;
    }

    public StringProperty buyerProperty() {
        return buyer;
    }

    public StringProperty conditionProperty() {
        return condition;
    }

}

요청하신 오류 메시지 입니다.

[DBG]----------------------------------------------------------------1
1002&2&RP_ID:RP5&DEP_ID:PD1&PD_NAME:연필&UNIT:ea&DATE:2020년 02월 21일&LOCATION:B00&NAME:황보승&TRADER:삼성&&
RP_ID:RP6&DEP_ID:PD2&PD_NAME:연필&UNIT:ea&DATE:2020년 04월 01일&LOCATION:A21&NAME:HHH&TRADER:삼성&&
※※※※※※※※※※※※
2
java.lang.NullPointerException
    at Admin.RPserch(Admin.java:266)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
    at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1769)
    at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Node.fireEvent(Node.java:8411)
    at javafx.scene.control.Button.fire(Button.java:185)
    at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
    at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
    at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
    at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
    at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:432)
    at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:410)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431)
    at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
    at com.sun.glass.ui.View.notifyMouse(View.java:937)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$3(WinApplication.java:177)
    at java.lang.Thread.run(Thread.java:748)
  • 오류 메시지도 같이 올려주세요. (텍스트로) 편집요청빌런 2020.4.14 12:45
  • [EXP] Tableview For input string: "TESTMSG" 이렇게 뜹니다. 알 수 없는 사용자 2020.4.14 13:19
  • catch 부분을 e.printStackTrace()로 바꾸고 나오는 메시지를 본문에 작성해주세요. 편집요청빌런 2020.4.14 14:22
  • 오류 메시지 올렸습니다! 알 수 없는 사용자 2020.4.14 14:39
  • 근본적인 해결은 아니지만 오류만 잡아드리면, Admin.java의 263번 째 줄이 아마도 int r = Integer.parseInt(testmsg[1]);겠죠? 여기에서 testmsg[1]을 Integer로 치환하려고 하나 숫자로 바꿀 수 없는 문자열이 할당되어 있어 NumberFormatException이 발생하고 있네요. 편집요청빌런 2020.4.14 15:15
  • 아 그렇네요.. 테스트 메시지 1번째 배열을 숫자로 보내야 하는데 문자로 보내고 있었네요..ㅠ 방금 다시 정확한 메시지를 보내니 다른 오류가 나오네요//ㅠ 알 수 없는 사용자 2020.4.14 15:37
  • 저런... 😩 편집요청빌런 2020.4.14 15:38
  • 다른 오류메시지로 수정했습니다. 알 수 없는 사용자 2020.4.14 15:38
  • Admin.java 266번 줄이 어디인가요? 편집요청빌런 2020.4.14 15:44
  • remark.setCellValueFactory(cellData -> cellData.getValue().remarkProperty()); 여기입니다. 알 수 없는 사용자 2020.4.14 16:01
  • remark, cellData, cellData.getValue() 셋 중에 하나가 null이라 발생하는 오류인데요. 브레이크 걸고 디버깅 해보세요. 편집요청빌런 2020.4.14 16:19
  • 넵. 한번 해보겠습니다.. 알 수 없는 사용자 2020.4.14 16:34
  • 휴... null값 뜨는건 @FXML 지정을 한꺼번에 해놔서 그런거였네요.... 알 수 없는 사용자 2020.4.16 12:28
  • 일단 완료하였습니다... 알 수 없는 사용자 2020.4.16 12:29
  • 👍 편집요청빌런 2020.4.16 12:36

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)