3 Replies - 2474 Views - Last Post: 16 April 2009 - 05:45 PM Rate Topic: -----

#1 cookie_272   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 05-April 09

Buffered input stream into two Dimentional char array

Posted 16 April 2009 - 05:25 AM

Hi,

I need to ream the file into this two dimentional char array. here is my code, it is well commented and explians everything in detail:
import java.io.*;
import java.util.*;

class XpInputStream
{
	public static void main (String args[]) throws IOException
	{
		String FilePath = "C:\\Users\\Admin\\Desktop\\pagefile1.sys";//File Path to the page File
			
			DataInputStream input = new DataInputStream(new BufferedInputStream(new FileInputStream(FilePath)));
			//Creates an input stream called input - sets it to a data input stream that has a File input stream
			//wraped in a buffered input stream.  File path set to String File Path - set above
		
		char sectors[][];//two dimentinal char array to store the Sector number followed by 1024 bytes of data in that sector
		
		int r;	//int r to hold the value of the byte
		while ((r = input.read()) != -1)
		{
			for(int SectorNumber = 0; SectorNumber < 10/*will be set to the lenght of the file*/; SectorNumber++)//works out
			//which sector number the program is reading. The lenght of the File. Increments sector number after each
			//sector has been read and stored
			{
				for(int i = 1; i<1024; i++)//count to the size of a sector. start at position 1 and works up to 1024
				  {
						  sectors[SectorNumber][r] =;//this is where the problem lies and I am unsure how to get the data read into r stored into r's position in the array.
				  }
			}
		}
	}
}


Thanks for your help, it is very much appreciated

Cookie_272

*Edited: Intermediate ranking ?

This post has been edited by pbl: 16 April 2009 - 05:46 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Buffered input stream into two Dimentional char array

#2 prajayshetty   User is offline

  • D.I.C Addict
  • member icon

Reputation: 31
  • View blog
  • Posts: 920
  • Joined: 27-April 07

Re: Buffered input stream into two Dimentional char array

Posted 16 April 2009 - 08:13 AM

by the way what you want your code to do is it a snippet or a tuitorial

This post has been edited by prajayshetty: 16 April 2009 - 08:13 AM

Was This Post Helpful? 0
  • +
  • -

#3 cookie_272   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 05-April 09

Re: Buffered input stream into two Dimentional char array

Posted 16 April 2009 - 08:20 AM

View Postprajayshetty, on 16 Apr, 2009 - 02:13 PM, said:

by the way what you want your code to do is it a snippet or a tuitorial


it's a snippet. My whole program working relies on me getting this to work. The rest of the program will not function without this.

if I can get this to work on it's own i can put it into the rest of the program no problem.

Thanks

cookie_272
Was This Post Helpful? 0
  • +
  • -

#4 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Buffered input stream into two Dimentional char array

Posted 16 April 2009 - 05:45 PM

And the question is ?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1