0
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Javaのファイルフォーマットごとのファイル読込方法のまとめ

Last updated at Posted at 2017-05-24

まとめ

Javaの外部ファイルの対応状況がよくわからなかったので、整理した。

拡張子 対応 利用法
*.csv 簡易的にはString.split(",",-1)メソッドによってパースできるが、ダブルクオーテーションや文字列中のカンマなど、CSVの方言に応じた例外処理が必要。
*.tsv String.split("\t",-1)メソッドによってパースする。
*.json JSON-P *1 またはJSON-B *2 を用いる。
*.xml SAX APIまたはDOM APIを用いる。
○・・・ファイルに対応するクラスが用意されている。
△・・・ファイルに対応するクラスはないが、比較的ラクにパースできる。
☓・・・考えたくもないほどパースが辛い。

*1 Java7以降で対応している。
*2 Oracleが提供しているがJava標準ではないらしい。

参考資料

0
5
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?