1.java源文件 扩展名

如题所述

java源文件的扩展名为”.java“。

解释:这个是固定规范,源文件顾名思义就是最原始的没有经过编译的文件,这个在java中就是”.java”

备注:编译后的文件扩展名是“.class”文件。

温馨提示:内容为网友见解,仅供参考
第1个回答  2010-09-13
源文件名是.java,编译后的class文件扩展名问.class
第2个回答  2010-09-13
java源文件 扩展名
源文件名是.java,编译后的class文件扩展名问.class
第3个回答  2015-09-10
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

package com.tij.io.file;

import java.io.File;

/**
* 获得文件扩展名
* @author guoyoujun
* @date 2014-3-17
*/
public class GetFileExtension {

/**
* java.io.File 本省并没有给我们提供获取扩展名的方法,所以就自己写了一个
* <p>当然了我这里并没有对文件存在做出判断, 实际你应该要exists判断的!
* @param args
*/
public static void main(String[] args) {
File file = new File("/Users/GYJ/java1.txt");
System.out.println("File extension is " + getFileExtension(file));
//file name with extension(没有扩展名)
file = new File("/Users/GYJ/temp");
System.out.println("File extension is " + getFileExtension(file));
//file name with dot(名字带点)
file = new File("/User/GYJ/a.b.c.txt");
System.out.println("File extension is " + getFileExtension(file));
//hidden files without extension(没有扩展名的隐藏文件)
file = new File("/Users/GYJ/.htaccess");
System.out.println("File extension is: "+getFileExtension(file));
}

/**
* 获取文件扩展名
* @param file
* @return
*/
private static String getFileExtension(File file) {
String fileName = file.getName();
if (fileName.lastIndexOf(".") != -1 && fileName.lastIndexOf(".") != 0) {
return fileName.substring(fileName.lastIndexOf(".") + 1);
} else {
return "";
}
}

}
out put===========
File extension is txt
File extension is
File extension is txt
File extension is:
第4个回答  2010-09-12
编译过的是.class 源代码是.java不知你是问这个不,java要执行必须先要编译,本回答被网友采纳
相似回答