0

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?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by BestJewSinceJC
0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.