Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.nio.file.Files;
- import java.nio.file.Path;
- import java.nio.file.Paths;
- import java.util.Scanner;
- import java.util.StringTokenizer;
- public class Application {
- public static void main(String[] args) throws Exception {
- Scanner stdin = new Scanner(System.in);
- System.out.print("Enter CSV file path: ");
- Path path = Paths.get(stdin.nextLine());
- System.out.print("Enter separator [comma by default]: ");
- String separator = stdin.nextLine();
- if (separator.isEmpty()) {
- separator = ",";
- }
- Scanner file = new Scanner(Files.newInputStream(path));
- while (file.hasNextLine()) {
- String line = file.nextLine();
- StringTokenizer tokenizer = new StringTokenizer(line, separator);
- while (tokenizer.hasMoreTokens()) {
- System.out.println(tokenizer.nextToken());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement