John Starr

Greenhorn
+ Follow
since Dec 01, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by John Starr

I have another question for you, also let me know if I am posting these things in the wrong thread for this forum. I have this code here:

I want to change the file name to FileStatistics but when I change the public class to FileStatistics I get this error code:

FileStatistics.java:16: error: cannot find symbol
filename=in.nextLine();
^
symbol: variable in
location: class FileStatistics
1 error

What do I have to do to change the File name where I won't get error codes when I compile?
12 years ago
Hey Paul, the thing I was wondering about was this error:

BasicFileAttributes attr =
Attributes.readBasicFileAttributes(file);

I read the other topic post by Sverre Moe that talked about the Java 7 Confusion and here is what was said.


According to many different tutorials there are some differences to the official JDK7.

Interface FileRef is not in JDK7
References to path.copyTo, but method does not exist. Must instead use Files.copy
References to a class called Attributes, but does not exist. BasicFileAttributes basic = Attributes.readBasicFileAttributes. Must instead use Files.getFileAttributeView.


Would I have to replace

BasicFileAttributes attr =
Attributes.readBasicFileAttributes(file);

with Files.getFileAttributeView? Sorry, I am a noob at this. I think I fixed the other 2 errors I had.
12 years ago
I am working on this tutorial and having a few issues. Here is the problem "Create a file using any word-processing program or text editor. Write an application that displays the file's name, containing folder, size, and time of last modification. Save file as FileStatistics.java"

Here is what I have:



And this is the errors that I receive when I try to compile it: (I am using jGRASP)

----jGRASP exec: javac -g FileStatistics.java

FileStatistics.java:3: error: cannot find symbol
import java.nio.file.attribute.Attributes;
^
symbol: class Attributes
location: package java.nio.file.attribute
FileStatistics.java:15: error: method getName in interface Path cannot be applied to given types;
System.out.println("File name is " + file.getName());
^
required: int
found: no arguments
reason: actual and formal argument lists differ in length
FileStatistics.java:18: error: cannot find symbol
Attributes.readBasicFileAttributes(file);
^
symbol: variable Attributes
location: class FileStatistics
3 errors

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

I think I may be getting errors because of some compatibility issues with Java 7. Is there anything you can see that might be causing it?

Thanks,

-John


Sana: Added code tags
12 years ago