ASDV-Java/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/TestFileClass.html
2023-03-21 11:43:38 -05:00

58 lines
4.0 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>TestFileClass.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
table {color: #888888; background-color: #313335; font-family: monospace}
.string {color: #6a8759}
.comment {color: #808080}
.whitespace {color: #505050}
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
.literal {color: #cc7832}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/TestFileClass.java</td></tr></table>
<pre>
<span class="comment">/*</span>
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
<span class="comment"> */</span>
<span class="literal">package</span> com.mycompany.lab6.exceptions_calebfontenot;
<span class="literal">import</span> java.util.Scanner;
<span class="comment">/**</span>
<span class="comment"> *</span>
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">class</span> TestFileClass {
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args) {
Scanner input = <span class="literal">new</span> Scanner(System.in);
System.out.print(<span class="string">&quot;</span><span class="string">Enter a file path or directory: </span><span class="string">&quot;</span>);
String filePath = input.nextLine();
testFile(filePath);
}
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> testFile(String filePath) {
java.io.File file = <span class="literal">new</span> java.io.File(filePath);
System.out.println(<span class="string">&quot;</span><span class="string">Does it exist? </span><span class="string">&quot;</span> + file.exists());
System.out.println(<span class="string">&quot;</span><span class="string">The file has </span><span class="string">&quot;</span> + file.length() + <span class="string">&quot;</span><span class="string"> bytes.</span><span class="string">&quot;</span>);
System.out.println(<span class="string">&quot;</span><span class="string">Can it be read? </span><span class="string">&quot;</span> + file.canRead());
System.out.println(<span class="string">&quot;</span><span class="string">Can it be written? </span><span class="string">&quot;</span> + file.canWrite());
System.out.println(<span class="string">&quot;</span><span class="string">Is it a directory? </span><span class="string">&quot;</span> + file.isDirectory());
System.out.println(<span class="string">&quot;</span><span class="string">Is it a file? </span><span class="string">&quot;</span> + file.isFile());
System.out.println(<span class="string">&quot;</span><span class="string">Is it absolute? </span><span class="string">&quot;</span> + file.isAbsolute());
System.out.println(<span class="string">&quot;</span><span class="string">Is it hidden? </span><span class="string">&quot;</span> + file.isHidden());
System.out.println(<span class="string">&quot;</span><span class="string">The absolute path to this file is </span><span class="string">&quot;</span> + file.getAbsolutePath());
System.out.println(<span class="string">&quot;</span><span class="string">Last modified on </span><span class="string">&quot;</span> + <span class="literal">new</span> java.util.Date(file.lastModified()));
}
}
</pre></body>
</html>