开发者

how can I import a file in java programming language

开发者 https://www.devze.com 2023-01-05 22:00 出处:网络
how ca开发者_如何学JAVAn I import a file in java programming languageYou don\'t import files in Java. You import classes.

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
0

精彩评论

暂无评论...
验证码 换一张
取 消