Results 1 to 10 of 10
Thread: read rows
- 04-20-2011, 01:13 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 36
- Rep Power
- 0
read rows
hii
am working in program i finished but i faced problem :
the file that i want to read it is like this
2 2
2 5
4 9
0 0
my code is
look when i put s and t !Java Code:public static void main(String[] args) { try { Scanner read = new Scanner(new File("file.in")); while(read.hasNext()) { ?????????????? } myLinkedList LL = new myLinkedList (); for(int i=1;i<=[COLOR="RoyalBlue"]t[/COLOR];i++) { LL.addLast(i); } LL.remove([COLOR="Orange"]s[/COLOR]); } // catch catch(Exception e) { System.out.println(e); } }
s is : 2 2 4
t is : 2 5 9
and stop reading when it is reach the 0 // i have no problem with this step
but what am stack in is how i can read file as the way i explained.
because this step is what i need to finish my project.Last edited by Andrew_2; 04-20-2011 at 01:15 PM.
-
Your code doesn't compile. Could you post real code instead? Thanks.
- 04-20-2011, 01:24 PM #3
Member
- Join Date
- Mar 2011
- Posts
- 36
- Rep Power
- 0
Look if it is like this :
It is compile and work !Java Code:public static void main(String[] args) { try { Scanner read = new Scanner(new File("file.in")); myLinkedList LL = new myLinkedList (); for(int i=1;i<=9;i++) { LL.addLast(i); } LL.remove(4); } // catch catch(Exception e) { System.out.println(e); } }
what i posted just to explain my problem where is it. =)
-
- 04-20-2011, 01:46 PM #5
Member
- Join Date
- Mar 2011
- Posts
- 36
- Rep Power
- 0
This linked list i implemented all functions that i need in other classes !
and my problem are not in the other classes my problem is in main !
did you see this input :
2 2
2 5
4 9
0 0
this my file that i want to read as a way that i mentioned earlier.
when i test my program by insert value s and t by my self . my code work correctly
but what i need to complete my program .. i have to read input file ..
and put vales of input file instead of s and t that in first code.
- 04-20-2011, 02:49 PM #6
Member
- Join Date
- Mar 2011
- Posts
- 36
- Rep Power
- 0
If you do not get the idea i will try to explain it more :
the program should read the file " input file" which has two columns s , and t.
every time the program read a value of t. it will put it in the for loop :
for(int i=1;i<=t;i++) // so t will change until reach 0 and program will stop.
so if it read
2 --> for(int i=1;i<=2;i++) .. so the size of linked list will be 2
6--->for(int i=1;i<=6;i++) ......................................... 6
9--->for(int i=1;i<=9;i++) ......................................... 9
and the same thing for remove method
the program should read the value s and put it here
LL.remove(s);
first time
LL.remove(2);
and then
LL.remove(2);
then
LL.remove(4);
also when reached 0 will stop ! the two implementations will happen at the same time
but i have no idea how to do that.Last edited by Andrew_2; 04-20-2011 at 03:00 PM.
- 04-21-2011, 12:03 PM #7
Member
- Join Date
- Mar 2011
- Posts
- 36
- Rep Power
- 0
Guys can anybody give me only the hint to solve this problem ?
1. i tried array .. but it does not work !
2. i said i have to try array inside linked list but that will force me to change my whole program.
- 04-22-2011, 05:17 AM #8
Member
- Join Date
- Mar 2011
- Posts
- 36
- Rep Power
- 0
why no one won't help me !
-
I can only speak for myself, and I still don't have a clue of what you're trying to do or what your problem is. I don't know if others are having the same problem though. I am hopeful that someone else smarter than me will be able to understand your problem/question and help you solve it. But if that doesn't happen soon, I would ask you to clarify things more if possible. Try to explain it to me as if I have no clue about your program, your code, your errors, etc, and that you have to explain it all to me.
Last edited by Fubarable; 04-22-2011 at 05:38 AM.
-
Similar Threads
-
Jtable rows
By riddhishah28 in forum AWT / SwingReplies: 3Last Post: 02-18-2011, 06:24 AM -
jxl repeating rows
By mermaid in forum New To JavaReplies: 0Last Post: 01-14-2011, 03:59 PM -
java.io.IOException: Unable to read entire block; 493 bytes read before EOF; expected
By kushagra in forum New To JavaReplies: 5Last Post: 10-17-2008, 02:13 PM -
Fetching rows from DB
By Java Tip in forum Java TipReplies: 0Last Post: 02-06-2008, 09:23 AM -
How to read block of rows from database tables
By lmenaria in forum JDBCReplies: 1Last Post: 08-08-2007, 01:22 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks