Click here to Skip to main content
15,913,685 members
Home / Discussions / Java
   

Java

 
AnswerRe: Find numbers in a given string Pin
toxcct19-Jan-09 1:41
toxcct19-Jan-09 1:41 
QuestionBest Method to Write ArrayLists Pin
Reagan Conservative15-Jan-09 8:34
Reagan Conservative15-Jan-09 8:34 
AnswerRe: Best Method to Write ArrayLists Pin
newbie_15-Jan-09 20:04
newbie_15-Jan-09 20:04 
GeneralRe: Best Method to Write ArrayLists Pin
Reagan Conservative16-Jan-09 3:55
Reagan Conservative16-Jan-09 3:55 
QuestionExtract metadata from WMV file using Java Pin
Java Developer - First Time15-Jan-09 6:32
Java Developer - First Time15-Jan-09 6:32 
GeneralRe: Extract metadata from WMV file using Java Pin
itsmani27-Jan-09 20:51
itsmani27-Jan-09 20:51 
AnswerThe very first step has nothing to do with Java. Pin
Naruki15-Feb-09 17:24
Naruki15-Feb-09 17:24 
Questionread coulm from file and store it to array Pin
newbie_15-Jan-09 3:05
newbie_15-Jan-09 3:05 
Hello guys
i am new to java and i have some problem that going to make my head explode
i am stuck on this thing for a week now

i need to read data file by column not by lines
for example
i have the following data file

6, 148, 72, 35, 0, 336, 0627, 50, 2
8, 183, 64, 0, 0, 233, 0672, 32, 2
1, 85, 66, 29 
1, 89, 66, 23, 94, 281, 0167, 21, 1
0, 137, 40, 35, 168, 431, 2288, 33, 2, 10, 9, 125
5, 116, 74, 0, 0, 256, 0201, 30, 1





i need to read it coulmn by coulmn and store it to arrays
for exaample the first array would be {6,8,1,1,0,5} and so on
all what i have done is read it line by line and thats not working for me
this what i've done so far


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]+" ");					
			}		
			
		}		
		
	}
}


HELP PLEASE Frown | :( Confused | :confused: Confused | :confused:
Question[Message Deleted] Pin
Michael Monin14-Jan-09 10:02
Michael Monin14-Jan-09 10:02 
AnswerRe: Simple java programming Pin
toxcct15-Jan-09 4:29
toxcct15-Jan-09 4:29 
GeneralRe: Simple java programming Pin
Michael Monin15-Jan-09 10:11
Michael Monin15-Jan-09 10:11 
GeneralYou are pimping your article in the help section. Pin
Naruki9-Feb-09 15:30
Naruki9-Feb-09 15:30 
GeneralRe: You are pimping your article in the help section. Pin
Michael Monin13-Feb-09 7:17
Michael Monin13-Feb-09 7:17 
JokeWhen I think back to my USENET days... Pin
Naruki15-Feb-09 17:21
Naruki15-Feb-09 17:21 
QuestionNeed to add links to changing image within iframe, Is this possible? Any help greatly appreciated!! [modified] Pin
bluedog286814-Jan-09 6:04
bluedog286814-Jan-09 6:04 
Answer[Message Deleted] Pin
bluedog286814-Jan-09 8:36
bluedog286814-Jan-09 8:36 
QuestionI have problem with bookmark(Javascript) in opera.It works in other browser. Pin
bhatted13-Jan-09 14:32
bhatted13-Jan-09 14:32 
AnswerRe: I have problem with bookmark(Javascript) in opera.It works in other browser. Pin
toxcct15-Jan-09 4:24
toxcct15-Jan-09 4:24 
QuestionNeed help with parameterized class or method Pin
David Crow13-Jan-09 7:36
David Crow13-Jan-09 7:36 
AnswerRe: Need help with parameterized class or method Pin
toxcct15-Jan-09 4:28
toxcct15-Jan-09 4:28 
GeneralRe: Need help with parameterized class or method Pin
David Crow15-Jan-09 4:51
David Crow15-Jan-09 4:51 
GeneralRe: Need help with parameterized class or method Pin
toxcct15-Jan-09 4:55
toxcct15-Jan-09 4:55 
QuestionRe: Need help with parameterized class or method Pin
David Crow15-Jan-09 5:01
David Crow15-Jan-09 5:01 
AnswerRe: Need help with parameterized class or method Pin
toxcct15-Jan-09 5:04
toxcct15-Jan-09 5:04 
GeneralRe: Need help with parameterized class or method Pin
David Crow15-Jan-09 5:16
David Crow15-Jan-09 5:16 

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.