Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i read a notepad file in java? [closed]

Tags:

java

file

notepad

im trying to create a restaurant system that will create food items and such from a menu.

ill be learning jdbc soon and im sure that would help but for now i think the simplest way is too create my menu in notepad.

whats the best way to line up and read from a notepad file like a menu.

please try speak clearly, im not exactly sure of all terminologies.

this one looks promising but ive no idea whats goin on.

/////////////////////////////////////////////////////////////////////

im still stuck with this.

ive decided too make a seperate mthod for reading the file.

ive tried every example i can think of. could someone just show me an example of how too define a files classpath.

if i type menu.txt it just doesnt work.

like image 834
OVERTONE Avatar asked Mar 16 '26 22:03

OVERTONE


2 Answers

Have a look at Sun's Java Tutorial

like image 90
oliver31 Avatar answered Mar 19 '26 12:03

oliver31


Easiest option is to simply use the Apache Commons IO JAR and import the org.apache.commons.io.FileUtils class. There are many possibilities when using this class, but the most obvious would be as follows;

List<String> lines = FileUtils.readLines(new File("untitled.txt"));

It's that easy.

"Don't reinvent the wheel."

Can I ask what sort of content/data you will be reading from this file as there may be other (even simpler) possibilities?

i.e.

Properties

foo="bar"

String Tokens

foo,bar,fu,baz

Let me know if you require more details with any of the processes I've mentioned.

like image 40
Alasdair Avatar answered Mar 19 '26 11:03

Alasdair



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!