| | |
Using a static method to read data from text file
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
I am need a little guidance here as to how I am to go about using a static method to read data from a text file. I know how to use a static method to write data to a text file, now I am wondering how to use a static method to read data from a text file. The following code is the code that read the data from the text file in the main method. Now that the code works in the main method, I am wondering how I can create a static method that does this. Thanks in advance to the person that has some ideas for me on this...
Java Syntax (Toggle Plain Text)
int index = 0; double[] surfaceGravity = new double[10]; File gravity = new File("surfaceGravityData.txt"); Scanner inFile = new Scanner(gravity); while (inFile.hasNextDouble()) { surfaceGravity[index] = inFile.nextDouble(); index++; }
•
•
Join Date: Jul 2007
Posts: 277
Reputation:
Solved Threads: 37
I'm not totally sure where you're stuck. Have you tried to google this? I did and the first result has an example of a static read . . .
are you unsure of the concepts? are you trying but getting an error? I'm sorry, I'm just not sure what it is you are asking
you can look here - first result returned might be helpful:
http://lmgtfy.com/?q=java+Reading+an...ing+text+files
are you unsure of the concepts? are you trying but getting an error? I'm sorry, I'm just not sure what it is you are asking
you can look here - first result returned might be helpful:
http://lmgtfy.com/?q=java+Reading+an...ing+text+files
![]() |
Similar Threads
- Reading a txt file into a swing component (Java)
- Plot Chart from a Txt file (Java)
- Trend charts from text files (Java)
- Traversing a text file into string, int, and special symbols (Java)
- How to insert data read from text file into linked list? (Java)
- How to write, then close, then read (Java)
- read info from txt file (Java)
- Urgent Help Needed!!!! Plzzz (Java)
- Help with a reservation program! GUI Messed XD (Java)
- Need Help with ArrayList sorting (Java)
Other Threads in the Java Forum
- Previous Thread: Toolkit class has no getDefaultToolkit method?
- Next Thread: Java+LDAP
Views: 1178 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Java
3d @param affinetransform android api apple applet application arc arguments array arrays automation binary bluetooth byte c# chat class classes click client code compare component corrupted database detection draw eclipse error event exception file fractal game givemetehcodez graphics gui guitesting helpwithhomework html ide image input integer j2me java java.xls javaprojects jmf jni jpanel julia keytool linux list loop map method methods mobile netbeans newbie number object oracle os pong print problem producer program programming project projectideas read recursion reflection replaysolutions rim scanner screen server set size sms socket sort sql string swing terminal test threads time transfer tree web windows






