473,320 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

i need a guide to use Java Scanner class

hi i need a guide on how to use the scanner class... i need to use Java Scanner class to read a text file and be able to print the text inside of it...

example :

i have a text file named "myFile.text"

inside of it there are text writen or listed on it...

Alvin
Simon
Dennes

now... my problem is... how can i use the scanner to read the text file and be able to print those names?

all i need is a guide...
Jan 31 '08 #1
7 5158
r035198x
13,262 8TB
hi i need a guide on how to use the scanner class... i need to use Java Scanner class to read a text file and be able to print the text inside of it...

example :

i have a text file named "myFile.text"

inside of it there are text writen or listed on it...

Alvin
Simon
Dennes

now... my problem is... how can i use the scanner to read the text file and be able to print those names?

all i need is a guide...
Read this and this.
Jan 31 '08 #2
Read this and this.
pls check my code if i have error... im having a error cant find symbol...

import java.util.*;
import javax.swing.*;
public class Struck{
public static void main(String args[]){
String Jop=JOptionPane.showInputDialog(null,"Input File Name: ");
Scanner scan=new Scanner(new File("Jop"));
while(scan.hasNext()){
System.out.println(scan.next());}
}
}
Jan 31 '08 #3
r035198x
13,262 8TB
pls check my code if i have error... im having a error cant find symbol...

import java.util.*;
import javax.swing.*;
public class Struck{
public static void main(String args[]){
String Jop=JOptionPane.showInputDialog(null,"Input File Name: ");
Scanner scan=new Scanner(new File("Jop"));
while(scan.hasNext()){
System.out.println(scan.next());}
}
}
1.) Use code tags when posting code.
2.) Read the links that I posted above. The second one shows you how to read a file using two methods.
Jan 31 '08 #4
JosAH
11,448 Expert 8TB
pls check my code if i have error... im having a error cant find symbol...
I'm sure you noticed that the compiler told you *what* symbol it can't find and on
*which* line it discovered this trouble; why didn't you transfer that information to
us? Do you want us to guess?

kind regards,

Jos
Jan 31 '08 #5
hi i need a guide on how to use the scanner class... i need to use Java Scanner class to read a text file and be able to print the text inside of it...

example :

i have a text file named "myFile.text"

inside of it there are text writen or listed on it...

Alvin
Simon
Dennes

now... my problem is... how can i use the scanner to read the text file and be able to print those names?

all i need is a guide...
i DON KNOW HOW TO DO THE USER INPUT IN JAVA?so tell me how to do it in programs?
Feb 16 '08 #6
r035198x
13,262 8TB
i DON KNOW HOW TO DO THE USER INPUT IN JAVA?so tell me how to do it in programs?
Read the replies in this thread.
Feb 16 '08 #7
Refer the URL : http://bytes.com/topic/java/insights...-scanner-class
It will be more useful to you.
Jul 31 '12 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Andrew Bell | last post by:
I'm doing a uni course in the UK and one of my semesters is about programming. This is just going to be compilied and executed with no menu just using command promt (javac classfile.class) I am...
1
by: 848lu | last post by:
hey i really need help...i got this code....basically im suppose to make a calender that allows a user to type in month and year .... and the calander displays it on the scree using...
1
by: klubbhead | last post by:
This part of my program needs to read from 4 parameter files and then displays them on the screen by clicking a different radio button. The program itself works, but my professor says that I have to...
3
by: dalearyous | last post by:
ok basically i need to write a program that will replace normal words in a sentence with pirate words. the trick is it needs to be able to take two word phrases. i went about this two different ways:...
6
by: aureao4 | last post by:
I'm new to Java and programming. I'm trying to code a payroll program and continue getting errors. The program worked last week, this week I have to add set, get and a class. I've written the class...
3
by: Energizer100 | last post by:
Hey. I'm new to Java and I'm trying to make a grades program for a class assignment. This is what I have so far. import java.util.Scanner; import static java.lang.System.out; public class...
1
by: tikney5 | last post by:
I need to modify my current program so that is uses a class to store and retrieve the employees name, hourly rate, and number of hourse worked. Use a constructor to initialize the employee...
3
by: 100grand | last post by:
Modify the Inventory Program to use a GUI. The GUI should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price...
1
by: jimgym1989 | last post by:
I dont get it..why is the error: Exception in thread "main" java.util.InputMismatchException this is my code /** * @(#)textFileRead.java * * * @author * @version 1.00 2008/10/17 */
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.