[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

class keyword

Posted on 2002-07-19
1
Medium Priority
?
238 Views
Last Modified: 2010-08-05
What is the keyword "class" doing in this statement?

InputStream stream = IconCache.class.getResourceAsStream(path);

this is from the method:
private Image createStockImage(Display display,
                               String path)
{
  try
  {
   InputStream stream = IconCache.class.getResourceAsStream(path);
   if (stream != null)
   {
     ImageData imageData = new ImageData(stream);
     if (imageData != null)
     {
       ImageData mask = imageData.getTransparencyMask();
       return new Image(display, imageData, mask);
     }
  }
  } catch (Exception e) {
  }
return null;
}

which is from IconCache.java, part of the FileViewer example in the Eclipse SWT
0
Comment
Question by:jdaues
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
gandalf94305 earned 200 total points
ID: 7165951
For any class X, X.class is the respective class object. Try String.class.getName(). The getResourceAsStream is a method defined in java.lang.Class (see below).

Cheers,
--gandalf.

java.lang.Class getResourceAsStream

public InputStream getResourceAsStream(String name)

    Finds a resource with a given name. This method returns null if no resource with this name is found. The rules for searching resources associated with a given class are implemented by the defining class loader of the class.

This method delegates the call to its class loader, after making these changes to the resource name: if the resource name starts with "/", it is unchanged; otherwise, the package name is prepended to the resource name after converting "." to "/". If this object was loaded by the bootstrap loader, the call is delegated to ClassLoader.getSystemResourceAsStream.

Parameters: name - name of the desired resource
Returns: a java.io.InputStream object.
Since: JDK1.1
See Also: ClassLoader
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question