Warning: include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/users/2/moriya-h5/web/confrage/java/io/file/file.html on line 2

Warning: include_once(http://www.confrage.com/bin/header.php): failed to open stream: no suitable wrapper could be found in /home/users/2/moriya-h5/web/confrage/java/io/file/file.html on line 2

Warning: include_once(): Failed opening 'http://www.confrage.com/bin/header.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/io/file/file.html on line 2
File | Java | 株式会社CONFRAGE
Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/io/file/file.html on line 17

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/io/file/file.html on line 17
File
Fileクラスは、コンストラクタの引数で指定したファイル又はディレクトリを操作するためのクラスです。
このクラスを使用してファイルを作成するには以下のようにします。

import java.io.File;
import java.io.IOException;

public class MkFile {
    public static void main(String[] args) {
        File fl = new File("C:\\a.txt");
            try {
                fl.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
    }
}
File#createNewFile()メソッドでc:\配下にファイルが作成されます。
但し、Fileクラスのコンストラクタの引数でC:¥¥a.txtとベタ書きしているため、これはWindows環境でのみ作成されます。
Unixではファイルの区切り文字には/(スラッシュ)を使用するためです。

このためFileクラスには pathSeparator というフィールドが用意されています。
このフィールド値は、システムに依存するため、Windowsでは¥を示しますし、Unixでは/を示します。
staticフィールドなので File.Separator というように記述します。

このクラスはファイルを作成したりすることは出来ますが、ファイルの中身を読み込んだり書き込んだりすることはできません。

Back to top

Information

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/io/file/file.html on line 79

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/io/file/file.html on line 79

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/io/file/file.html on line 88

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/io/file/file.html on line 88