Results 1 to 10 of 10

Thread: read rows

  1. #1
    Andrew_2 is offline Member
    Join Date
    Mar 2011
    Posts
    36
    Rep Power
    0

    Default 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
    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);
            }
    
        }
    look when i put s and t !

    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.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  3. #3
    Andrew_2 is offline Member
    Join Date
    Mar 2011
    Posts
    36
    Rep Power
    0

    Default

    Look if it is like this :

    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);
            }
    
        }
    It is compile and work !
    what i posted just to explain my problem where is it. =)

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by Andrew_2 View Post
    Look if it is like this :

    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);
            }
    
        }
    It is compile and work !
    what i posted just to explain my problem where is it. =)

    I'm still confused. Where in this code do you read in any data from the file?

  5. #5
    Andrew_2 is offline Member
    Join Date
    Mar 2011
    Posts
    36
    Rep Power
    0

    Default

    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.

  6. #6
    Andrew_2 is offline Member
    Join Date
    Mar 2011
    Posts
    36
    Rep Power
    0

    Default

    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.

  7. #7
    Andrew_2 is offline Member
    Join Date
    Mar 2011
    Posts
    36
    Rep Power
    0

    Default

    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.

  8. #8
    Andrew_2 is offline Member
    Join Date
    Mar 2011
    Posts
    36
    Rep Power
    0

    Default

    why no one won't help me !

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    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.

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

Similar Threads

  1. Jtable rows
    By riddhishah28 in forum AWT / Swing
    Replies: 3
    Last Post: 02-18-2011, 06:24 AM
  2. jxl repeating rows
    By mermaid in forum New To Java
    Replies: 0
    Last Post: 01-14-2011, 03:59 PM
  3. Replies: 5
    Last Post: 10-17-2008, 02:13 PM
  4. Fetching rows from DB
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-06-2008, 09:23 AM
  5. Replies: 1
    Last Post: 08-08-2007, 01:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •