Copying a name.class file to a String Array or String

Can't use filestream don't understand why?

Page 1 of 1

9 Replies - 1733 Views - Last Post: 27 June 2009 - 05:02 AM Rate Topic: -----

#1 smith123456  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 24-June 09

Copying a name.class file to a String Array or String

Post icon  Posted 24 June 2009 - 10:46 AM

I have a class file. I do not have the java file. The class file is in the same folder as the driver foler or demo folder. I am creating the object in the driver file and then trying to call methods that are public and return a string in the name.class file. I am trying to copy the name.class file into a string or a string array by calling methods are public and return a string in the driver folder. I don't understand why I can't create the object and then call the method from the class file.


import java.util.*;

public class Demo  {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String MovieTitle;
		String rating;
		double firstWeekRev;
		
		MovieList[] name = new MovieList();
		name.getFieldNames();
		name.getMovieRec();
		
		
		
		
		// TODO Auto-generated method stub

	}

}



the movie list is the class file

classname variablename;
variablename = new classname;

I have tried putting in a constructor but it freaks when I do that. Would the constructor go before the object or after it. It would make sense to me it would go after it because a constructor set the values of the instance variables.

Is This A Good Question/Topic? 0
  • +

Replies To: Copying a name.class file to a String Array or String

#2 pbl  Icon User is offline

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

Reputation: 8342
  • View blog
  • Posts: 31,880
  • Joined: 06-March 08

Re: Copying a name.class file to a String Array or String

Posted 24 June 2009 - 11:03 AM

name is an array of MovieList

so if MovieList as a method getFieldNames() you need to call it from one element of the array like

name[10].getFieldNames();

also even if you created an array of MovieList you will have to put a MovieList in each of them

name = new MovieList[10];
for(int i = 0; i < 10; name.length; i++) {
   name[i] = new MovieList();
}


This post has been edited by pbl: 24 June 2009 - 11:16 AM

Was This Post Helpful? 0
  • +
  • -

#3 smith123456  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 24-June 09

Re: Copying a name.class file to a String Array or String

Posted 24 June 2009 - 11:11 AM

View Postpbl, on 24 Jun, 2009 - 10:03 AM, said:

name is an array[b] of MovieList

so if MovieList as a method getFieldNames() you need to call it from [b]one
element of the array like

name[10].getFieldNames();

also even if you created an array of MovieList you will have to put a MovieList in each of them

name = new MovieList[10];
for(int i = 0; i < 10; name.length; i++) {
   name[i] = new MovieList();
}



[/quote]

???

This post has been edited by pbl: 24 June 2009 - 11:17 AM

Was This Post Helpful? 0
  • +
  • -

#4 smith123456  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 24-June 09

Re: Copying a name.class file to a String Array or String

Posted 24 June 2009 - 11:28 AM

MovieList can't be resolved as a type error. I don't know how big the array is. Its huge. Can the class file be thought of as a txt file. I just need this read in and copied into the array as a long string.


import java.util.*;

public class Demo  {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String MovieTitle;
		String rating;
		double firstWeekRev;
		/*
		public MovieList(String movieTitle, String rating, double firstWeekRev)
		{
			title = movieTitle;
			score = rating;
			rev = firstWeekRev;
		}
		
		*/
		
		
		//movie list can't be resolved into a type
		MovieList name[] = new MovieList();
		   	name = MovieList[1000];
			name = new MovieList[1000];
			for(int i = 0; i < 1000; name.length; i++) {
			   name[i] = new MovieList();
			}

		
		
		name[0].getFieldNames();
		name[1].getMovieRec();
		name[2].getmovieTitle();
		name[3].getrating();
		
		name[10].getFieldNames();

		
		
		// TODO Auto-generated method stub

	}

}



classname variablename
variablename = new classname

Why is this saying "movielist can't be resolved into a type. The method calls aren't throwing errors.
Was This Post Helpful? 0
  • +
  • -

#5 pbl  Icon User is offline

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

Reputation: 8342
  • View blog
  • Posts: 31,880
  • Joined: 06-March 08

Re: Copying a name.class file to a String Array or String

Posted 24 June 2009 - 11:34 AM

		MovieList name[] = new MovieList();
			   name = MovieList[1000];
			name = new MovieList[1000];



just the correct syntax will do :)

		MovieList name[] = new MovieList[1000];


Was This Post Helpful? 0
  • +
  • -

#6 smith123456  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 24-June 09

Re: Copying a name.class file to a String Array or String

Posted 24 June 2009 - 11:39 AM

MovieList is the class file. It still says type can't be resolved.
Was This Post Helpful? 0
  • +
  • -

#7 pbl  Icon User is offline

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

Reputation: 8342
  • View blog
  • Posts: 31,880
  • Joined: 06-March 08

Re: Copying a name.class file to a String Array or String

Posted 24 June 2009 - 12:01 PM

You dont have the files MovieList.java and MovieList.class in the same directory as Demo.java ?
Was This Post Helpful? 0
  • +
  • -

#8 smith123456  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 24-June 09

Re: Copying a name.class file to a String Array or String

Posted 24 June 2009 - 12:18 PM

I have the MovieList.class file I do not have the MovieList.java file nor will I. I have to take the MovieList.class file and copy into a string or an array or something as one large string and print it to the screen. This should take like 10 minutes or that's what I was told lol The MovieList.class file is in the same folder as the Demo.java file or the Driver.java file

Nor do I know how big the class file is.

I give for the day. I am just going to play with it. Just thought I was doing something simple that was stupid. There is more to it than I thought.
Was This Post Helpful? 0
  • +
  • -

#9 pbl  Icon User is offline

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

Reputation: 8342
  • View blog
  • Posts: 31,880
  • Joined: 06-March 08

Re: Copying a name.class file to a String Array or String

Posted 24 June 2009 - 06:11 PM

View Postsmith123456, on 24 Jun, 2009 - 11:18 AM, said:

I have the MovieList.class file I do not have the MovieList.java file nor will I. I have to take the MovieList.class file and copy into a string or an array or something as one large string and print it to the screen.

This does not make sense... somebody is playing April fool on you
Was This Post Helpful? 0
  • +
  • -

#10 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2780
  • View blog
  • Posts: 11,765
  • Joined: 20-September 08

Re: Copying a name.class file to a String Array or String

Posted 27 June 2009 - 05:02 AM

Please attach the MovieList class as a file, renaming the extension
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1