-4

I am trying to parse files with different extension types in my Java program. I just got a strange file which has a unique file format as below.

20121126.033111.vikeng8.28088

I am not sure what is the extension of this particular file. Windows shows type as 28088 File. I think its some kind of a text file. I was not able to find any further information from Google. I can open it in Notepad++ and Notepad.

How can I determine this file extension type from Java? What would be the extension in general for these kind of files?

Further, I need to open this file and read some information from it. Any help would be very useful as i am seeing this kind of strange file for the first time.

4

2 回答 2

1

文件扩展名不可靠

那只是Windows版本的服务器,但显然文件名是可以更改的。因此,不幸的是,由用户给文件起一个合理的名称。

Unix 有用于检测文件类型的库。例如,该命令file example.cc将输出类似C++ source, ASCII text, with very long lines.

我假设它是一封电子邮件或类似的东西,然后您可以将其视为mbox文件。

不过,如果您不确定文件扩展名,请假设它不正确并执行正确的文件类型检测。

参见例如:如何可靠地检测文件类型?

于 2012-11-26T18:28:31.307 回答
1

扩展名并不一定意味着什么——例如,在 .jpg 文件上添加 .txt 扩展名并不意味着它不再是 .jpg——文件类型通常由内容决定;扩展名应该是内容的线索。

关于你的问题——这个文件的扩展名确实是 .28088——尽管这并没有给出所有内容的指示。Java 不能告诉你任何不同的东西。

于 2012-11-26T18:26:10.037 回答