Kevin Carr

Greenhorn
+ Follow
since Jan 19, 2010
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 Kevin Carr

Once more thank you. I was originally wanting to do this project in python, because I knew it had easy lists and dictionaries, but I wanted to build up on my java knowledge.
13 years ago
Thank you. Does the == just not return correctly or what when using strings?
13 years ago
You shouldn't need to. If the font really is to small zoom in on your web browser or copy it to a text editor. I was trying to not take up the entire page with code. The indentations just happen inbetween the curly braces so not that big of a deal.
13 years ago
I got down what to do to get the names and whatnot, but when I run the program all the files go into the 'other' folder. Also the prompt spits out this:

J:\>cd J:\organizer

J:\Organizer>javac Organizer.java

J:\Organizer>java Organizer
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException:
11
at Organizer$beginListener.actionPerformed(Organizer.java:83)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)




public class beginListener implements ActionListener {
public void actionPerformed(ActionEvent a) {
String dir = enterDirectory.getText();
File directory = new File(dir);
File[] files = directory.listFiles();

if( audio.isSelected()){
new File(dir + "/Audio").mkdir();
}
if( video.isSelected()){
new File(dir + "/Video").mkdir();
}
if( pictures.isSelected()){
new File(dir + "/Pictures").mkdir();
}
if( documents.isSelected()){
new File(dir + "/Documents").mkdir();
}
if( application.isSelected()){
new File(dir + "/Applications").mkdir();
}
if( other.isSelected()){
new File(dir + "/Other").mkdir();
}
for(int i = 0; i <= files.length; i++) {
String d = files[i].getName();
String choppedFilename;
String extension;
int dotPlace = d.lastIndexOf('.');
if(dotPlace >= 0){
choppedFilename = d.substring(0, dotPlace);
extension = d.substring(dotPlace + 1);
} else {
choppedFilename = d;
extension = "";
}

if(extension == "aac" || extension................................................ extension == "midi"){
if(audio.isSelected()) {
files[i].renameTo(new File(dir + "/Audio", d));
}
}
else if(extension == "doc" || extension == "docx" || extension == "log" || extensi..................... || extension == "part" || extension == "py"){
if(documents.isSelected()){
files[i].renameTo(new File(dir + "/Documents", d));
}
}
else if(extension == "app" || extension == "bat" || extension == "cgi" || exten........................ension == "rom" || extension == "sav"){
if(application.isSelected()){
files[i].renameTo(new File(dir + "/Applications", d));
}
}
else if(extension == "bmp" || extension == "gif" || extension == "jpg" || extensio.......................extension == "icb" || extension == "vst" || extension == "tiff"){
if(pictures.isSelected()){
files[i].renameTo(new File(dir + "/Pictures", d));
}
}
else if(extension == "3g2" || extension == "3gp" || extension == "asf" || ext.........................== "xvid"){
if(video.isSelected()){
files[i].renameTo(new File(dir + "/Video", d));
}
}
else {
if(other.isSelected()){
files[i].renameTo(new File(dir + "/Other", d));
}
}

}


}

Where is the problem in the processing of file extensions that causes this? The dots represent great amounts of file extensions
13 years ago
Basically I am trying to get teh total number of files but I don't know the right method because .length apparently is a different method in the io.file class. Says cannot find symbol, symbol : method length()
location: class java.io.file[]
13 years ago
I am trying to create a for loop that goes as long as there are files in a directory.

String dir = enterDirectory.getText();
File directory = new File(dir);
File[] files = directory.listFiles();
for(int i = 0; i < files.length(); i++) {
}

What exactly am I doing wrong? When I run it it returns an error. Is there anyway I could get it to retun all of the files in the directory as a string array instead of a file array?
13 years ago
so I could just type out :

new file(sometingsometing).mkdir();


and it would make that directory?
13 years ago
So you have to create a boolean then assign it to new file.mkdir()? Why does the third try fail but the fourth succeed?
13 years ago
I need to make a folder in a given directory so I decided to use the mkdir function, but every example I have looked at is completely different with no common grounds. How do I functionally use the mkdir function to create a file folder?
13 years ago
If I create a jar of a program using the java media framework, will others be able to run it without needing the jmf?
13 years ago
Ok, thank you, I guess I should've asked if there was a class in the core api that would manage this function. If I use this other library and then package the application as a jar, will the user need this libraryinstalled also?
13 years ago
What method would I use to retrieve data from a webcam or live camera connected to the users computer?
13 years ago
I am thinking of using a database. What does that involve doing? Sorry, never really made a program dealing with the internet before.
13 years ago
Hmmmm. ok. I was originally thinking keeping the program as a jar and then have a text file stored on their main drive that holds all of the new words, but I think maybe using an actual program installed into the program files. How exactly would I do that? and how would I make the installer? I know several other languages if that helps.
13 years ago