【发布时间】:2013-08-03 04:33:07
【问题描述】:
我主要使用 C++ 进行编程,并且一直致力于将我的游戏移植到带有 Android 的 Java 上。 我的一些代码遇到了一个小问题。 我的文本文件是这种格式:
0:1 0:0 1:1 2:2 3:3
我使用 fscanf 函数读取它,如下所示:
for(int Y = 0;Y < MAP_HEIGHT;Y++) {
for(int X = 0;X < MAP_WIDTH;X++) {
Tile tempTile;
fscanf(FileHandle, "%d:%d ", &tempTile.TileID, &tempTile.TypeID);
TileList.push_back(tempTile);
}
如何读取 Java 中显示的格式化数据?显然没有 fscanf lol afaik...
【问题讨论】:
-
你试过
Scanner类吗?检查this SO post。 -
现在正在调查,谢谢。
-
看看这个 [topic][1] 所以你可能会使用 java.util [1] 中的 Scanner 类:stackoverflow.com/questions/16981232/…
标签: java android file text formatted