Hi all,
as I write in the title I want to change the code of an application I built in Java.
The software consists in reading some files organized in table and
for each row
for each column
if you find A(row,col)==1 then
find if in this column there are other 1
If the matrix is NxM the complexity is O(Nx(M^2)). The problem is that M=some thousand and N=400 elements.
When I wrote this in java I used a TextFile Reader to get the text:
for (int index=0;index<files.size();index++){
TextFileReader reader=new TextFileReader(files.get(index).getAbsolutePath());
reader.read();
fullText[index]=reader.getText();
}
Then I split all file in lines and all lines in tokens, like this:
String[] lines = fullText[indFile].split("\n"); // split whole file into lines
String[] tokens = lines[2].split("\t");
The I visit all the tokens once a time.
Maybe I don't know so well Java language but it seems that using this code the process is very very slow and I would that the execution is approximately real time.
Is there someone that can tell me what approach is better to use....?
How can I do it with threads? Is this better?
Thanks to all
Angelo
as I write in the title I want to change the code of an application I built in Java.
The software consists in reading some files organized in table and
for each row
for each column
if you find A(row,col)==1 then
find if in this column there are other 1
If the matrix is NxM the complexity is O(Nx(M^2)). The problem is that M=some thousand and N=400 elements.
When I wrote this in java I used a TextFile Reader to get the text:
for (int index=0;index<files.size();index++){
TextFileReader reader=new TextFileReader(files.get(index).getAbsolutePath());
reader.read();
fullText[index]=reader.getText();
}
Then I split all file in lines and all lines in tokens, like this:
String[] lines = fullText[indFile].split("\n"); // split whole file into lines
String[] tokens = lines[2].split("\t");
The I visit all the tokens once a time.
Maybe I don't know so well Java language but it seems that using this code the process is very very slow and I would that the execution is approximately real time.
Is there someone that can tell me what approach is better to use....?
How can I do it with threads? Is this better?
Thanks to all
Angelo