imu_1's Profile User Rating: -----

Reputation: -6 Shunned
Group:
Active Members
Active Posts:
256 (0.36 per day)
Joined:
03-June 11
Profile Views:
1,683
Last Active:
User is offline Jun 21 2012 10:11 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   imu_1 has not set their status

Posts I've Made

  1. In Topic: How to reuse a thread multiple times

    Posted 10 Mar 2012

    pbl, you got it!

    Thanks everyone for your response. I tried what pbl advised and it worked.
  2. In Topic: Reading one word at a time usinf random access file

    Posted 8 Feb 2012

    Let me be more specific:

    I have text file like this:

    america mexico canada
    china india australia
    brazil chile russia

    I want to use thr random excess file to read up to the word india and store the words in an array. Then start reading from australia
    up to the end and store in another array.

    Here's my code:

    raf.seek(0);  
        System.out.println("The second number is " + raf.readLine());
        StringTokenizer tokens;
    	tokens = new StringTokenizer(line); 
    	int i = 0; 
    	long start = raf.length()/2;
    
    	while (line != null && i < start) 
       {
         
    	while(tokens.hasMoreTokens())
    				System.out.println(tokens.nextToken());
        line = raf.readLine();
        tokens = new StringTokenizer(line); 
    	i++;
       }
    
    
    


    What i need help on is how to read up to the word india using seek method. I tried to find the entire length of the file and divided it by two so that I can read up the middle, but it seems not to be working
  3. In Topic: Distributing words among two processes

    Posted 31 Jan 2012

    thanks man
  4. In Topic: Distributing words among two processes

    Posted 31 Jan 2012

    I have gotten this far now:
     
        			  List list = load.getFile(); 
    			
    	                   int begin = 0; 
    			
    			for(int i = 1; i <= num; i++)
    			 { 
    			    end = (list.size()/num) *i;
    				
    			    process[i] = rt.exec("java subProcess"); 
    			// get an ObjectOutputStream for sending data to the child 
    	         OutputStream os = process[i].getOutputStream();
    	         ObjectOutputStream obj = new ObjectOutputStream(os);
                 obj.flush();  // outputs the bytes to another outputstream 
                   System.out.println("Parent sending: " + list.subList(begin, end));
    				// send the ArrayList to the child
    	           objos.writeObject(list.subList(begin, end)); 
    			   obj.flush();
                  begin = end+1; 
    			  
    			}
    
    


    I am however getting this error:



    C:\JAVA>java MultiProcess
    Enter the number of processes : 2

    Parent sending: [child, mango, orange, zebra, theory, tomato]
    java.io.NotSerializableException: java.util.RandomAccessSubList
    at java.io.ObjectOutputStream.writeObject0(Unknown Source)
    at java.io.ObjectOutputStream.writeObject(Unknown Source)
    at MultiProcess.main(MultiProcess.java:49)

    It doesnt allow me to sned the data to the child process. Why ?
  5. In Topic: Distributing words among two processes

    Posted 31 Jan 2012

    Suppose I have amethod called getArray() that returns the arrayList of thousand string words.
    Runtime runtime = Runtime.getRuntime();
    // Create a child process
    Process process = runtime.exec("java subProcess");

    OutputStream output = process.getOutputStream();
    ObjectOutputStream obj = new ObjectOutputStream(output);
    obj.flush();

    obj.writeObject(getArray()); // sending the array to the child process for further processing
    objos.flush();

    As you can see, I am only creating one process and sending the entire doc to it. I would like to create two processes, split the doc into half and send the first half to the first process and second half to the second process.

My Information

Member Title:
D.I.C Regular
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

Comments

imu_1 has no profile comments yet. Why not say hello?