how to splite a Reader-file into 2 dimensional array?
package readtext;
import java.io.*;// For input & output classes
import java.util.Date;// For the Date class
public class input {
public input() {
}
public static void main(String[] args)
{
try
{
String dirName = "C:/Documents and Settings/seng/Desktop/testfile"; // Directory for the output file
String fileName = "data.txt"; // Name of the output file
File output = new File(dirName, fileName);
output.createNewFile();// Create a new file if necessary
if(!output.isFile())// Verify we have a file
{
System.out.println("Creating " + output.getPath() + " failed.");
return;
}
BufferedWriter out = new BufferedWriter(
new FileWriter(output.getPath(), true));
BufferedReader in = new BufferedReader(
new FileReader("C:/Documents and Settings/seng/Desktop/testfile/txt.txt"));
String[] text = {in.readLine()};// String to be segmented
// Write the proverbs to the file preceded by the string length
for(int i = 0; i < text.length; i++)//read the whole line
{
out.write(text);
out.flush();
}
out.close();
}
catch(IOException e)
{
System.out.println("Error writing the file " + e);
}
}
}
currently i have a data.txt which contain of 3 x 3 data
123
456
7 89
the information do not arrange properly.
if i using the readLine() to read the string, then i will only get the 1st row data (1 23) output in the txt.txt file..may i know that any1 know how to get for the 2nd and 3rd row of data?
Message was edited by:
wilfrid100

