Ask your own question, for FREE!
Computer Science 23 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!
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!