Hi,
I am stuck in building 2D Array from StringBuffer. I am reading data from a file and store it in a StringBuffer object by appending "\n" at the end. My read method is in the following.

public void tmFileReader() throws IOException {
		
		Work wrk=new Work();
		StringBuffer buffer=new StringBuffer();
		FileInputStream fstream = new FileInputStream(this.tmFileName);
		DataInputStream in = new DataInputStream(fstream);
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		String input=this.inputStringReader();
		int i=0;
		
		
		
		String strLine;
		
		//dataArray=new char[100][100];
	    //Read File Line By Line
	   while ((strLine = br.readLine()) != null)   {
	      // Print the content on the console
	     // System.out.println (i+"--index--"+strLine);
		   
		   buffer.append(strLine).append("\n");
		   i++;
	       }
		  
	   wrk.Simulate(buffer, input, i);
		  in.close();
		
	      }

Now I pass the buffer to another method where I want to build a 2D Char array from it.

public void Simulate(StringBuffer myBuffer, String inputString,int number){
		
		
		int length=myBuffer.length();
		int i=0;
		
		while(i<length){
			
			
			
		}	
		
		
	}

I am stuck here. Can anyone help me please?

Why do you want to make it into a 2d char array, and how? As far as I know StringBuffer is represented by an underlying char array. How do you want to make it into a 2d one?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.