Tout est dans le titre, je recherche un équivalent de fscanf en Java.
Pour rappel, voici l'utilité de fscanf en C:
<font class="small">Code:</font><hr /><pre>
FILE *fp;
char msg[512];
int nb,i,dontCare,j;
fp = fopen(path, "rt");
if (!fp) return 1;
strcpy(msg,"");
while (strcmp(msg,"Mesh")) {
nb = fscanf(fp,"%s\n",msg);
if (nb!=1) return 2;
}
nb = fscanf(fp,"%s\n",msg);
if (nb!=1) return 2;
nb = fscanf(fp,"%s\n",msg);
if (nb!=1) return 2;
nb = fscanf(fp,"%d;\n",&(data->nbVertices));
if (nb!=1) return 2;
data->verticesList = (vertexData*)malloc(data->nbVertices*sizeof(vertexData));
if (!data->verticesList) return 3;
for (i=0;i<data->nbVertices-1;i++) {
nb = fscanf(fp,"%f;%f;%f;,\n", &(data->verticesList.x), &(data->verticesList.y), &(data->verticesList.z));
if (nb!=3) return 2;
}
...
</pre><hr />
Pour rappel, voici l'utilité de fscanf en C:
<font class="small">Code:</font><hr /><pre>
FILE *fp;
char msg[512];
int nb,i,dontCare,j;
fp = fopen(path, "rt");
if (!fp) return 1;
strcpy(msg,"");
while (strcmp(msg,"Mesh")) {
nb = fscanf(fp,"%s\n",msg);
if (nb!=1) return 2;
}
nb = fscanf(fp,"%s\n",msg);
if (nb!=1) return 2;
nb = fscanf(fp,"%s\n",msg);
if (nb!=1) return 2;
nb = fscanf(fp,"%d;\n",&(data->nbVertices));
if (nb!=1) return 2;
data->verticesList = (vertexData*)malloc(data->nbVertices*sizeof(vertexData));
if (!data->verticesList) return 3;
for (i=0;i<data->nbVertices-1;i++) {
nb = fscanf(fp,"%f;%f;%f;,\n", &(data->verticesList.x), &(data->verticesList.y), &(data->verticesList.z));
if (nb!=3) return 2;
}
...
</pre><hr />