简体   繁体   中英

How do I set up a scanner object in JAVA?

I'm trying to write a program that will read in a file of students academic credit data and create a list of students on academic warning. I first need to set up a scanner object to scan from the input file. I am new to java and need step by step instructions.

最简单的解决方案通常是在问一个问题之前进行一些研究,例如使用google,但是由于这是您的第一个问题,我想,我会给您答案

Scanner scanner = new Scanner(new File(filename));
Scanner input = new Scanner(new File("filename.extenstion"));

In the beginning of your program, make sure you have

import java.util.Scanner;

as your first line. Continuing, you should create a scanner in your program.

// Create a Scanner Scanner input = new Scanner(System.in);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM