Click here to Skip to main content
15,911,142 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to get the instance that called a method. Pin
Pete O'Hanlon15-Jan-09 4:02
mvePete O'Hanlon15-Jan-09 4:02 
GeneralRe: How to get the instance that called a method. Pin
DaveyM6915-Jan-09 4:03
professionalDaveyM6915-Jan-09 4:03 
GeneralRe: How to get the instance that called a method. Pin
DaveyM6915-Jan-09 6:35
professionalDaveyM6915-Jan-09 6:35 
GeneralRe: How to get the instance that called a method. Pin
Pete O'Hanlon15-Jan-09 9:43
mvePete O'Hanlon15-Jan-09 9:43 
GeneralRe: How to get the instance that called a method. Pin
Jon Rista16-Jan-09 6:54
Jon Rista16-Jan-09 6:54 
Questionread coulmn from file and store it to array Pin
sudany_zool15-Jan-09 2:58
sudany_zool15-Jan-09 2:58 
AnswerRe: read coulmn from file and store it to array Pin
SeMartens15-Jan-09 3:04
SeMartens15-Jan-09 3:04 
GeneralRe: read coulmn from file and store it to array Pin
sudany_zool15-Jan-09 3:31
sudany_zool15-Jan-09 3:31 
thanks for you help
this is what i've done so far
i read the data in array line by line
the problem that the line lenth is not equal as i illustrate in the example
i am still stuck


public class VariableTransformation 
{
	
	private String FileName = "";
	private FileReader FileReader;	
	private BufferedReader buffFile;
	private ArrayList<string[]> attrDomainList = new ArrayList<string[]>();	
	private String[] item=null;
	
	
		
	
	
	public static void main(String[] args) 
	{
		VariableTransformation tds = new VariableTransformation();
		Scanner input=new Scanner(System.in);
		System.out.println("===============================================");
		System.out.print("Enter the file name>> ");
		String filename;
		filename=input.next();
		tds.fileLoad(filename);
		System.out.println("===============================================");
			
	}
	
	public void fileLoad(String fileName)
	{
		String line = "";
		String[] attrDomain;
		FileName = fileName;
			
		
		System.out.println("> Reading File..");
		try {
			int lineCount=0;
			int size=0;
			FileReader = new FileReader(FileName);
			buffFile = new BufferedReader(FileReader);

			try {
												
				while((line = buffFile.readLine()) != null)
				{
						item = line.split(",");
						size=item.length;
						attrDomain=new String[size];
						for (int i = 0; i < item.length; i++) {
							attrDomain[i]=item[i];							
						}						
						attrDomainList.add(attrDomain);
						lineCount++;
				}
				
				printData(attrDomainList);
				System.out.println("> Finish File Reading.");
				System.out.println("Number of Lines>> "+lineCount);
				System.out.println("===============================================");
				
			} 
			catch (IOException e) {
				System.out.println(e.getStackTrace().toString());
				System.out.println("# Error while reading file .");
			}
			finally
			{				
				try {buffFile.close();} catch (IOException e) {e.printStackTrace();}
				try {FileReader.close();} catch (IOException e) {e.printStackTrace();}
			}
		} catch (FileNotFoundException e) {
			System.out.println("> Error. Target File Don't exist.");
			e.printStackTrace();
		}	
	}
	
	
	private void printData(ArrayList<string[]> dataFile )
	{
		int Counter=0;				
		for (int i = 0; i < dataFile.size(); i++) {
			System.out.print("["+(++Counter)+"] ");			
			for (int j = 0; j < dataFile.get(i).length; j++) {
				System.out.print(dataFile.get(i)[j]+" ");					
			}		
			
		}		
		
	}
}

GeneralRe: read coulmn from file and store it to array Pin
SeMartens15-Jan-09 3:42
SeMartens15-Jan-09 3:42 
GeneralRe: read coulmn from file and store it to array Pin
sudany_zool15-Jan-09 3:59
sudany_zool15-Jan-09 3:59 
QuestionReaderWriterLock Pin
the_jat15-Jan-09 2:30
the_jat15-Jan-09 2:30 
AnswerRe: ReaderWriterLock Pin
Luc Pattyn15-Jan-09 2:53
sitebuilderLuc Pattyn15-Jan-09 2:53 
AnswerRe: ReaderWriterLock Pin
Jon Rista16-Jan-09 6:57
Jon Rista16-Jan-09 6:57 
AnswerRe: ReaderWriterLock Pin
Mark Salsbery16-Jan-09 7:50
Mark Salsbery16-Jan-09 7:50 
QuestionDrawing cards from a deck Pin
Tony Pottier15-Jan-09 2:18
Tony Pottier15-Jan-09 2:18 
AnswerRe: Drawing cards from a deck Pin
CPallini15-Jan-09 2:41
mveCPallini15-Jan-09 2:41 
GeneralRe: Drawing cards from a deck Pin
Tony Pottier15-Jan-09 4:01
Tony Pottier15-Jan-09 4:01 
AnswerRe: Drawing cards from a deck Pin
benjymous15-Jan-09 2:50
benjymous15-Jan-09 2:50 
GeneralRe: Drawing cards from a deck Pin
Tony Pottier15-Jan-09 4:03
Tony Pottier15-Jan-09 4:03 
GeneralRe: Drawing cards from a deck Pin
Tony Pottier15-Jan-09 4:16
Tony Pottier15-Jan-09 4:16 
GeneralRe: Drawing cards from a deck Pin
benjymous15-Jan-09 4:55
benjymous15-Jan-09 4:55 
GeneralRe: Drawing cards from a deck Pin
Guffa15-Jan-09 5:56
Guffa15-Jan-09 5:56 
AnswerRe: Drawing cards from a deck [modified] Pin
Luc Pattyn15-Jan-09 5:38
sitebuilderLuc Pattyn15-Jan-09 5:38 
GeneralRe: Drawing cards from a deck Pin
Guffa15-Jan-09 6:32
Guffa15-Jan-09 6:32 
GeneralRe: Drawing cards from a deck Pin
Tony Pottier15-Jan-09 6:40
Tony Pottier15-Jan-09 6:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.