4.2.2Reader/Writerを利用する
ではこれらのクラスを使ってテキストファイルにアクセスするサンプルを作成しながら、具体的な処理の仕方を見ていくことにします。例によって第3章で作成したMyFXAppプロジェクトを書き換えて利用することにしましょう。
まずは、FXMLファイルでGUIを作成します。以下のように変更してください(<? import ?>タグは新規追加するもの以外省略します)。
<BorderPane prefHeight="200.0" prefWidth="300.0" fx:id="border"
xmlns="http://javafx.com/javafx/8"
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="jp.tuyano.eclipsebook.WindowController">
<center>
<TextArea fx:id="ta" />
</center>
<bottom>
<HBox alignment="CENTER">
<Button fx:id="b1" text="Load" onAction="#doAction" />
<Button fx:id="b2" text="Save" onAction="#doAction" />
</HBox>
</bottom>
</BorderPane>
今回
この記事は会員限定です。会員登録をすると続きをお読みいただけます。
ログイン / 新規登録