import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class ReadFile {
public static void main(String[] arges) throws IOException{
String path = "E:/testProject/test.txt";
int value = getString(path);
System.out.println(value);
}
public static int getString(String path) throws IOException{
try {
String com;
String comma = ",";
FileReader fileReader = new FileReader(path);
BufferedReader bufferedReader = new BufferedReader(fileReader);
com = bufferedReader.readLine();
String[] allComma = com.split(comma);
int nu = allComma.length;
fileReader.close();
return nu;
} catch (FileNotFoundException e) {
e.printStackTrace();
return 0;
}
}
}
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class ReadFile {
public static void main(String[] arges) throws IOException{
String path = "E:/testProject/test.txt";
int value = getString(path);
System.out.println(value);
}
public static int getString(String path) throws IOException{
try {
String com;
String comma = ",";
FileReader fileReader = new FileReader(path);
BufferedReader bufferedReader = new BufferedReader(fileReader);
com = bufferedReader.readLine();
String[] allComma = com.split(comma);
int nu = allComma.length;
fileReader.close();
return nu;
} catch (FileNotFoundException e) {
e.printStackTrace();
return 0;
}
}
}