|
Q:
|
Create your initial project:
-
Download project.zip.
-
Extract the archive
-
Open the resulting Task/pom.xml
file in your IntelliJ IDE as a project.
Depending on your operating system of choice absolute
(=fully qualified) filenames are being represented
differently:
- Windows:
-
C:\Users\student\Desktop\Downloads\avira_v3.zip
Such path names may be decomposed into:
- UNIX-like (Mac-OS, Linux,...):
-
/usr/share/gpa/gpa-logo.png
Possible decomposition:
Implement a class FileMetaInfo to be
instantiated from strings describing absolute or relative
filenames. Your class shall have several attributes corresponding
to the previously described values. Consider the following usage
example:
Due to the possible presence of drive letters Windows
pathnames are more difficult to parse. We illustrate a possible
strategy dissecting
C:\programms\openvpn\conf\hdm.ovpn into the
desired constituents:
- Decomposing path components:
-
C:\programms\openvpn\conf\hdm.ovpn
→ {"C:", "programms",
"openvpn", "conf",
"hdm.ovpn"}.
- Drive letter string to character
normalization
-
"C:" → 'C'
- Decomposing filename (if required)
-
"hdm.test.ovpn" →
{"hdm.test", "ovpn"}
Hints:
-
You will have to deal with absolute and relative (e.g.
../../Desktop/var.png) filename
specifications.
-
You will have to deal with files having no extensions
like e.g. /usr/bin/firefox. In this case
the extension attribute is expected to be null.
-
For the sake of limiting complexity do not consider
filenames starting with a period (like
/home/heinz/.bashrc).
-
Read Java File Separator
vs File Path Separator.
-
Assembling path components may be effected by either
using a StringBuffer
instance. Mind the distinction between relative and absolute
paths!
-
The backslash “\” must be escaped when
being part of a Java™ String
literal:
String path = "C:\\programms\\openvpn\\conf\\hdm.ovpn";
|