Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- /*Con file TXT del tipo:
- A:B:C
- D:E:F
- G:H:I
- L:M:N*/
- public class LetturaconTokenizer {
- public static void main (String[] args) {
- try {
- FileReader f = null;
- f=new FileReader("prova.txt");
- BufferedReader b;
- b = new BufferedReader(f);
- String lettura;
- while ((lettura = b.readLine()) != null)
- {
- StringTokenizer st = new StringTokenizer(lettura, ":");
- while (st.hasMoreTokens())
- {
- String A = st.nextElement().toString();
- String B = st.nextElement().toString();
- String C = st.nextElement().toString();
- System.out.println(A);
- System.out.println(B);
- System.out.println(C);
- }
- }
- b.close();
- } catch(Exception e) { //???
- e.printStackTrace(); //???
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment