Ask your own question, for FREE!
Computer Science 11 Online
OpenStudy (anonymous):

In java, how to get an input from a text file?

OpenStudy (anonymous):

First import java.io.*; and java.util.*; than there are so many build-in class that can do the jobs .But if you are to use Scanner class than you can easily do the work..for that In the main class Scanner in = new Scanner(new FileReader("text.in")); //take the file that should be located in the same directory otherwise put location of path like ("c://home/Documents") ....// BufferedWriter inp = new BufferedWriter(new FileWriter("textout.txt")); In scanner class there are so many methods in.next()//read by character in.hasNext(); in.nextLine();read line by line... please refer this link ..

OpenStudy (anonymous):

Thanks :))

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Arriyanalol: i need help
20 hours ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
23 hours ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!