how ca开发者_如何学JAVAn I import a file in java programming language
You don't import files in Java. You import classes.
The syntax is as follows:
import com.my.Class;
There is nothing like the #include available in C/C++. If you really want to actually "include" files into your source, you need to rethink your design.
If by import a file you meant read a file, there are several ways, probably the most common of which are using the Scanner and BufferedReader objects. Have a look at
http://java.sun.com/javase/6/docs/api/java/util/Scanner.html
and
http://java.sun.com/javase/6/docs/api/java/io/BufferedReader.html
respectively for information on how to use them.
Take a look at Packages:
- http://tinf2.vub.ac.be/~dvermeir/java/other_doc/JavaPackages.html
- http://java.sun.com/docs/books/tutorial/java/package/packages.html
精彩评论