I'm not sure how to read files and use the file lines in some other function of a program. For example, right now I'm trying to read a file of char's and then assign those each item into an array so I can access them later. If you could help, let me know!
How to read and write files
Started by Adriann, Aug 03 2009 05:00 PM
10 replies to this topic
#1
Posted 03 August 2009 - 05:00 PM
|
|
|
#2
Posted 03 August 2009 - 05:59 PM
What is your code? It could be something simple.
#3
Posted 04 August 2009 - 10:09 PM
Reading, Writing, and Creating Files (The Java™ Tutorials > Essential Classes > Basic I/O)
show us some code if you want more detailed help.
show us some code if you want more detailed help.
#4
Posted 05 August 2009 - 01:03 AM
Maybe you can learn from this example.
it's pretty useless method, but you can edit it in any way you need.
it's pretty useless method, but you can edit it in any way you need.
public void readFile(String file) throws IOException{
FileReader input = null;
BufferedReader bufRead;
String line;
input = new FileReader(file);
bufRead = new BufferedReader(input);
line="";
while(line != null){
line = bufRead.readLine();
System.out.println(line); // prints the line
}
bufRead.close();
}
#5
Posted 05 August 2009 - 11:06 AM
that's all I needed to see. thanks!
#6
Posted 06 August 2009 - 11:37 PM
nice script....
#7
Posted 07 August 2009 - 02:19 PM
#8
Posted 15 August 2009 - 12:10 AM
its' not a script.
God is real... unless declared an integer
my blog :: http://techarraz.com/
#9
Posted 15 August 2009 - 10:49 PM
#10
Posted 23 August 2009 - 04:39 AM
Let's just call it Code Snippet
#11
Posted 23 August 2009 - 06:55 AM


Sign In
Create Account

Back to top










