directory 1 « directory « Java I/O Q&A





1. Java - get the newest file in a directory?    stackoverflow.com

Does anybody have a snippet of Java that can return the newest file in a directory (or knowledge of a library that simplifies this sort of thing)?

2. How can I get the location of the JDK directory in Java?    stackoverflow.com

Is there an similar property like System.getProperty("java.home") that will return the JDK directory instead of the JRE directory? I've looked http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#getProperties() and there doesn't seem to be anything for ...

3. How do you get resin to serve index.html by default if you navigate to a directory? (equivalent of DirectoryIndex in Apache)    stackoverflow.com

Is it possible to configure Resin to serve static files such that navigating to e.g. http://localhost:8888/foo/bar/ will serve the file foo/bar/index.html (without performing a redirect)? I can't ...

4. How to set the execution directory with JCreator (Pro)?    stackoverflow.com

Is it possible, to execute a class in a specified directory? I mean, a.class is in directory abc and i want it to be executed as if it were in directory xyz ...

5. How do you add a directory of java classes to a project?    stackoverflow.com

I have a Java project I'm working on, and wish to include a directory full of classes. These are the "JEdit Syntax" classes, and come within two packages:

org.syntax.jedit
org.syntax.jedit.tokenmarker
However, everywhere I ...

6. Java: Proper Way of Making Directories    stackoverflow.com

Directories some_folder, some_folder_1, some_folder_2, and some_folder_3 don't exist initially.

File folder1 = new File("some_folder/some_folder_1"); 
File folder2 = new File("some_folder/some_folder_2"); 
File folder3 = new File("some_folder/some_folder_3"); 

if(!folder1.exists()) {
    folder1.mkdirs();
}

if(!folder2.exists()) {
  ...

7. Using a 'lib' directory with intellj IDEA (v6)    stackoverflow.com

I've got an Ant task (using the maven task) set up to automatically download all my Java apps dependencies and consolidate them into a lib directory, but I cant see a ...

8. Problem with creating a directory in Java    stackoverflow.com

I am trying to create a directory in Java. I think I have provided correctly all necessary things so that I make the directory, but it is not created. You can ...

9. How do I run a java program from a different directory?    stackoverflow.com

I have a java program that I would like to be able to run from anywhere on my machine. I would like to run it from my Cygwin command prompt. ...





10. In java: Take snapshot of a directory and restore it    stackoverflow.com

Is there a library to take a folder, take a snapshot of its content, do some modifications and then restore it to its previous state from directly from a java program ...

11. java: creating directories    stackoverflow.com

in windows batch and and bash scripts there is %USERPROFILE% and ~, is there a command that works the same in java that will allow me to switch to the users ...

12. How do I refer to the right Directory?    stackoverflow.com

If my Java Class is in: `

package org.gamehost.flyingame.BookManagementServlet.ModelClass
aka:
BookManagementSoftwareServlet/org/gamehost/flyingame/BookManagementServlet/ModelClass
and in that class, if I want to return a file from a directory, say an html file, after ...

13. File.createNewFile() thowing IOException No such file or directory    stackoverflow.com

I have a method that writes to a log file. If the file exists it should append to it, if not then I want it to create a new file.

if (!file.exists() ...

14. Download a directory over HTTP in Java    stackoverflow.com

I have some files in a directory tree which is being served over HTTP. Given some sub-directory A, in that directory tree I want to be able to download directory A ...

15. Method in Java to create a file at a location, creating directories if necessary?    stackoverflow.com

I am attempting to write a file using java.io, where I am trying to create it at the location "some/path/to/somewhere/then-my-file". When the file is being created, any of the directories on ...

16. Creating a File in a new Directory    stackoverflow.com

I came up with the follwing code...my Document is not created. I dont get any Error messages. Regarding the Java API i did everything in the right order. The directory is created ...





17. How to tell if a directory is remotely mounted using Java    stackoverflow.com

Is there a way to determine programatically if a particular directory is actually remotely mounted? Can this be done with Java, and if not can it be done with native C ...

18. best practice for directory polling    stackoverflow.com

I have to do batch processing to automate business process. I have to poll directory at regular interval to detect new files and do processing. While old files is being processed, ...

19. Java import from other directory    stackoverflow.com

I am building a Enterprise Service Bus (ESB) with Java. I won't get into details But I have to build multiple servers who make use of the same classes. I have ...

20. Create all directories up to a point?    stackoverflow.com

I need to be able to build all directories up to and including the directory specified by my File object. For example, suppose I have something like this:

File file = new ...

21. java What action should be considerd for button using as a browse to attach file or directory    stackoverflow.com

I make a JFrame form which contains two text fields and two buttons. I need this form works as when user clicks first button will browse to attach file and second button ...

22. java hsperfdata directory    stackoverflow.com

Java creates hsperfdata directory usually in the /tmp directory. What purpose does this directory serve ? What is the effect on the JVM if this directory is accidentally deleted ?

23. Program not running from expected directory?    stackoverflow.com

I am working on a web-based program, using Java. I am not sure exactly how to phrase this, but I expect the program to be running from within the c:/Resin/webapps/apps ...

24. Override the Local module directory for cvs using Hudson    stackoverflow.com

I'm using Hudson and I need to change the checkout directory for cvs. Instead of checkout/update the project under the workspace dir, I'd like to specify a dir (as you can ...

25. Best way to iterate through a directory in java?    stackoverflow.com

hi all I'm new to java and searching for code relating to getting a list of all files in a directory (including files in subfolders) yields tons of different approaches. What ...

26. Program to get all files within a directory in Java    stackoverflow.com

I'm working on this program to get all the files in the directory. For some reason I am getting a NullPointerException on Line 16. I don't know why though ...

27. I am using emma for building my project and I'm not getting directories like coverage    stackoverflow.com

see the error below

Buildfile: F:\gqmaps\gqmaps9\build.xml
init:
compile:
    [javac] Compiling 106 source files to F:\gqmaps\gqmaps9\out
    [javac] Note: Some input files use unchecked or unsafe operations.
    ...

28. Create directory using Java    stackoverflow.com

How do i create Directory/folder once i have tested System.getProperty("user.home"); i have to create a directory (directory name "new folder" ) if and only if new folder does not exist. Thanks

29. how to get directory using file object?    stackoverflow.com

File file=new File("c:\\temp\\java\\testfile");
testfile is a file,it's maybe not exists, i want to get directory c:\\temp\\java\\ using file object how to do it? thanks :)

30. Using File to create directory which contains periods    stackoverflow.com

File testDir = new File("C:\temp\test");
testDir.createNewFile();
As I understand it, the above will create a directory called test in the directory c:\temp
File testDir = new File("C:\temp\test.dir");
testDir.createNewFile();
As I understand it, the above will create ...

31. JAVA ZipFile entries() method doesn't see directories    stackoverflow.com

I'm working on digital documents and digital signatures and I've stumbled upon a problem. Input: documentX.adoc - zip file with files and folders inside. I need to get all the content in the ...

32. How does one atomically replace a directory with another one in Java?    stackoverflow.com

I have a directory that contains data files served to clients, say, /srv/data. While making a series of updates, I am working on /srv/data_tmp, and at the end of the operation, ...

33. How to iterate over the files of a certain directory, in Java?    stackoverflow.com

Possible Duplicate:
Best way to iterate through a directory in java?
I want to process each file in a certain directory, in Java. What is the ...

34. How to get only 10 last modified files from directory using Java?    stackoverflow.com

HI, i'm beginner and i found an old thread about lastmodified files in java. What i want is to get only 10 recent files from a directory and move them to another ...

35. How to get the classloader's directory information?    stackoverflow.com

Would like to build the absolutepath use this information. Anyone knows how?

36. How to get ftl files from directory and subdirectry    stackoverflow.com

I want to get complete list of ftl file from directory and their subdirectory with their relative path. For example suppose if I have a ftl file in D:\abc\pqr\lmn\try.ftl and I ...

37. Getting file details and not printing directory help    stackoverflow.com

I am trying to make a program which will print all files in my current directory (but not the directories), and at the moment what I have is printing all files ...

38. Create File object of file from parent directory in java    stackoverflow.com


I have this issue of accessing a file in one of the parent directories.
To explain, consider the following dir structure:-

C:/Workspace/Appl/src/org/abc/bm/TestFile.xml  
C:/Workspace/Appl/src/org/abc/bm/tests/CheckTest.java
In the CheckTest.java I want ...

39. Creating directories problem    stackoverflow.com

Can't figure out why this keeps creating 2 folders? It makes a '0' folder and whatever the jobID is from the html. I want uploaded files in the jobID folder, not ...

40. How do I load instances of a certain class from a java directory?    stackoverflow.com

Here's my method: Feature[] getFeatures(File dir) I'm trying to go through the directory, check each class file. Any class that is of type 'Feature', I want to load an instance of it. Then ...

41. How to create a directory in memory? pseudo file system / virtual directory    stackoverflow.com

For my usecase, I would like to have an in memory directory to store some files for a very short time. Actually I compile source code to .class files at runtime, ...

42. Java: How to create torrent file for multiple files or directories?    stackoverflow.com

The next code is a part of jBitTorrent API for Java a bit modified by me:

            if (!torr.saveAs.matches(""))
   ...

43. Readings files from a directory    stackoverflow.com

I need to read each file from a directory to parse them individualy when I give a directory structure. I check if it excists and if its valid .. etc and I ...

44. in java,how to watch multiple directories    stackoverflow.com

i want to monitor the multiple folders whether new files are added in the folders. if files are added in folder,i want to get he name of the file. How to do ...

45. Java NullPointerException when calling listFiles() on a directory    stackoverflow.com

I have a series of folders containing books on a server which I am accessing with this piece of code. I want to make each of these folders an object so ...

46. How to create a file in a directory in java?    stackoverflow.com

If I want to create a file in C:/a/b/test.txt can I do someting like

File f = new File("C:/a/b/test.txt");
and use FileOutputStream to create the file? If so, how? For some reason the ...

47. Where is my java directory?    stackoverflow.com

In Maven2 i've created the maven-archetype-webapp. I see the webapp and resource directory, but where is my JAVA directory? Do I create it manually, and if so, would I need ...

48. How to sort files from a directory by date in java?    stackoverflow.com

I have a method which reads the content from files located in a directory. But for functional reasons it is necessary to start with the oldest file (indicated by the property ...

49. How expensive is File.exists in Java    stackoverflow.com

Hallo, I am wondering who File.exists works. I'm not very aware of how filesystems work, so I should maybe start reading there first. But for a quick pre information: Is a call to File.exists ...

50. Java - creating new file, how do I specify the directory with a method?    stackoverflow.com

I know how to write a file to a specified directory by doing this: public void writefile(){

try{
    Writer output = null;
    File file = new File("C:\\results\\results.txt");
 ...

51. TrueZip - How to decompress inner jar/zip files without expanding them as directories?    stackoverflow.com

I'm creating a tzp file using TrueZip 7, and the cp_rp method to add all directory contents at once to the tzp file. After that, I'm trying to extract all contents of ...

52. Problem With SAX Parsing in Java    stackoverflow.com

So I asked a question earlier just to brush up on some basics of SAX and I learned a lot from the answers. From what I learned, I tried to create ...

53. MSBuild - Running a Java program for every file is a directory    stackoverflow.com

I just started playing around with MSBuild this evening and am porting an nAnt build script over to MSBuild. Compiling seems pretty straight forward, but one thing I want to ...

54. Java's createNewFile() - will it also create directories?    stackoverflow.com

I've got a conditional to check if a certain file exists before proceeding (./logs/error.log). If it isn't found I want to create it. However, will

File tmp = new File("logs/error.log");
tmp.createNewFile();
also create logs/ ...

55. isDirectory() returns true for a file    stackoverflow.com

in my java program I copy a file and delete the new file. In my method removeFile() I check if it is a directory:

String fileName = "G:/1310628353186Examples.csv";
File f = new File(fileName);
if (f.isDirectory()) ...

56. Java - Strange directory problem?    stackoverflow.com

When I run a class with the following code:

public static void main(String[] args)
{
    createDuplicateStructure("in", "out");
}

public static void createDuplicateStructure(String path_start, String path_result)
{
    File start = new ...

57. Non-recursive way to get all files in a directory and its subdirectories in Java    stackoverflow.com

I am trying to get a list of all files in a directory and its subdirectories. My current recursive approach is as follows:

private void printFiles(File dir) {
  for (File child ...

58. How do I create a new directory at the location of an existing file?     stackoverflow.com

I'm fairly new to Java so please forgive me if this is a stupid question. Basically, a file is a song. I'm using JFileChooser to select multiple songs. I then do some ...

59. Determine if a directory contains a file    stackoverflow.com

I have java.io.File objects A and B, where A represents a directory and B represents a file. B can be an absolute path or a relative path that is 0 or ...

60. Java file directory for multiple users    stackoverflow.com

i have a plugin which is going to be used more than one client, and the plugin has to access a file to load some arrays in java

fFile = new File("file ...

61. Java directory polling strategy    stackoverflow.com

In directory arriving files in unpredictable time, but suppose that probability distribution is normal. Average intervals for polling must be 1 minute. Exists some strategy - e.g. change near 20% (+ ...

62. What's wrong with URLClassLoader when working with directories?    stackoverflow.com

This is my code:

File folder = /* the folder with a.txt file */
final URL[] urls = new URL[] {
  folder.toURI().toURL()
};
ClassLoader loader = new URLClassLoader(urls);
assertThat(loader.getResource("/a.txt"), is(notNullValue()));
Doesn't work. getResource() returns NULL. Why? ...

63. Java formatter - setting file directory    stackoverflow.com

i am trying to create a text file in a folder (called AMCData). The file is called "File" (for the sake of this example). I have tried using this code:

public static void ...

64. How to poll directory to check whether new file is added?    stackoverflow.com

I want to poll a directory to check whether new file is added to the directory. If any new file is added I want to read that file. Can anybody give ...

65. Cannot make file java.io.IOException: No such file or directory    stackoverflow.com

I am trying to create a file on the filesystem, but I keep getting this exception java.io.IOException: No such file or directory I have an existing directory, and I am trying to ...

66. Discovering the reason for File.mkdirs() failure    stackoverflow.com

If I call one of the methods File.mkdir() or File.mkdirs() in Java, and it returns false, is there a way to know why was the directory not created?

67. in java how to get files in a given directory    stackoverflow.com

I want to write a java code, where given a directory name, I should be able to get all the files starting with list (so something like list*) and read each ...

68. getResource with parent directory reference    stackoverflow.com

I have a java app where I'm trying to load a text file that will be included in the jar. When I do getClass().getResource("/a/b/c/") , it's able to create the URL ...

69. how to prevent (programmatically) a java application from starting if it's not in a pre-defined directory?    stackoverflow.com

how to prevent (programmatically) a java application from starting if it's not in a predefined directory? Example: I have application.jar and I want to make it runnable only if it's located in ...

70. Java .isDirectory() return true also on file without extension    stackoverflow.com

I've noticed that checking if an instance of a File class is a Directory with the method isDirectory() this method return true also for file without an extension . For example if ...

71. Directory-based projects in IntelliJ    stackoverflow.com

I have created a new project (from existing sources) in IntelliJ (10.5 community edition) and I selected to make it directory based. IntelliJ wanted to commit only one .iml file, which ...

72. Parse out Wikipedia markup from files in a directory    stackoverflow.com

I used lucene's ExtractWikipedia tool to extract a bz2 dump of the latest english wiki pages. The resulting .txt files still have the wikipedia markup language in them. Is there a ...

73. How can I sort files in a directory in java?    stackoverflow.com

Here is my code and it works ! But I want to be able to sort the files list according to name, size, modification date and more

import java.io.File;
import org.apache.commons.io.FileUtils;

public class StartingPoint ...

74. WatchService / Deletions / File or Directory?    stackoverflow.com

I want to detect if a file or directory has been deleted. Obviously I can't use Files.isDirectory(Path) and the equivalent for files, because the file/directory is already deleted. I thought about using ...

75. Getting multiple java files directory    stackoverflow.com

I need go through a package with sub-packages that contains some java class file. Can someone teach me how to get all those java class file directories and store it in ...

76. Directory problem    bytes.com

P: 14 dorito This is not a reply to Luron31 ... but for some reason I cannot create a new thread. So excuse me for temporarily highjacking the thread. I am ...

77. Phone directory remove directory    bytes.com

Ok if that is what is wrong, then How can I make it delete the entry? I thought decrementing the size of the array would be deleting an entry out of ...

78. Browsing a Directory is it possible..?    bytes.com

I creating a program and I'm done with my design. my program contains 2radiobuttons, 3textfields and 3buttons. the flow of my program is to browse a single file and directory... my ...

79. checking to see if a directory exists    bytes.com

Have you checked the documentation for the SftpClient class? I would have guessed that the client instance is what lets you check for the existence of directories, create them and copy ...

80. Wrong directory in Notepad++    bytes.com

I am a complete rookie at programming, and I've installed NotePad++ on my laptop so I can practise writing scripts outside of uni. I've also installed JDK v 1.6.0 (Java Development ...

81. creating directories issues    bytes.com

82. custom directory in siteminder    coderanch.com

83. filter the directories    coderanch.com

84. Making new directories    coderanch.com

Hi All, I am having some trouble making directories using File class. Can someone help please? Here is my code: public void saveJava() { try { newFile = new File("JavaSrc\\"+fileName+".java"); newFile.createNewFile(); } catch(IOException io) { io.printStackTrace(); } try { ras = new RandomAccessFile(newFile,"rw"); String theString = "" + mainCodeString; ras.writeUTF(theString); } catch (IOException io) { io.printStackTrace(); } try { ras.close(); } ...

85. ZipOutputStream and Directories    coderanch.com

I've begun working on a back-up mechanism for my application's data, which simply involves using java.util.zip to compress all of my data and write it out to a ZIP file. Using a ZipOutputStream seems very easy in this manner, except... all of my data files are stored in distinct directories. But when I write all of those files to a ZIP ...

86. How to go in the back to back directory ?    coderanch.com

I have a properties file which lies in the folder c:\com and I have a java class in c:\com\org\dtd folder which loads the properties file. If I specify the path of the properties file like (in the java class )- "..\\..\\dtd.properties", I get the FileNotFound Error. How do I move to the back to back directory ?

87. creating directories...HELP    coderanch.com

I am running a set of JSP and servlet pages on a development server, and the purpose is to create a set of folders and subfolders on a different doc server. The path is being read from a text file and when we point the path to a folder on the same server as the files are running, there is no ...

88. Can I create a new file with a directory?    coderanch.com

Hi, Another question. Can I create a new file and a directory at the same time? For example, my current working directory is D:\working, then I want to create a file named logFile.log and want to put it to the 'logs' subdirectory of the working directory ('logs' subdirectory does not exist.). I try this 'File logFile = new File("D:\\working\\logs\\logFile.log")' in WinNT, ...

89. Detect new file in a directory    coderanch.com

I assume you mean that you want to check when a new file is put into a directory. I had to do something like this once. Here's what I did: Using java.io.File.listFiles() I got an array of files in the directory. And then after a period of time, something like 5 secs which is configurable, I used some set operations to ...

90. How to remove a file from a directory?    coderanch.com

91. ClassLoader and directories    coderanch.com

92. How to create a file in specified directory    coderanch.com

Hi I am trying to create a file in a directory in append mode.Its not getting creayed.here is the code.Can you please help me. FileWriter fNew = new FileWriter("C:/xml/newXML.xml,true); i am able to create a file directly under c:/ like FileWriter fNew = new FileWriter("C:/newXML.xml,true); when i try to create in xml directory which is already exists under c its giving ...

93. Putting file in directory    coderanch.com

I managed to create directory in a server . But I am unable to put any newly created files into the dir even though i specify the full path. Below is my code. It just create files with the name of the path attached whereas it is the path of the dir I want it to create to. The funny thing ...

94. Creating a sub sub directory    coderanch.com

Hi, I need to create a sub sub directory. That means a directory inside a directory that I also create. Then I have to put a file inside which I also create. Below are my code. Is it correct ? String subDirPath = "MANUAL"; File myFile = new File(subDirPath); if(!myFile.exists()) myFile.mkdir(); String SubDir2 = subDirPath+"/"+subename; File submyFile = new File(SubDir2); if(!submyFile.exists()) ...

95. Look through files in a directory    coderanch.com

How do I get a list of the files in a directory? I am aware of JFileChooser but it is not what I am looking. I need to search the contents of the xml files in the directory. I can do this with one file but need to do it with them all.

96. Compare two directories    coderanch.com

Hi guys, I am really cracking my head over this one. If you have two dirs, how can you compare the two? ie. does the second dir match the template? I am looking at passing the two directories as arguments at command line. I can do the simple part like recursively going thru directory and subdirectories. Any ideas??? Below is my ...

97. Comparing directories - revisited    coderanch.com

Hi java friends. I am back again. Last week I asked you for ideas on how to compare directory structures and I would like to thank you for the wonderful suggestions - Jason and Stan. My apologies for posting this as a new topic but I thought I would catch your attention faster this way. Here is what I have done ...

98. Creating directory using mkdirs()    coderanch.com

99. How to create directory and subdirectory with files.    coderanch.com

any body give me suggestions I have copy one directory(it has contains files & subfolder and sub folder has files and subfolder) ex: d:\source it contains one,two 2 folders,readme.txt 1 files d:\source\one d:\source\two d:source\readme.txt. one folder contains sample.txt d:\source\one\sample.txt and two folder,contains two files and sub folder (three). d:\source\two\sample1.txt d:\source\two\sample2.txt d:\source\two\three Three sub folder,contains one gif files d:\source\two\three\samples.gif I need these ...

100. directories and sub directories.    coderanch.com

hello friends , i faced aproblem : i want to scan all directories of "homeDir" to copy a trial file into them but i can't copy the file except the first level of the dir.. that means if i searched a multi level tree of directory i can't access all its levels ! what can i do ? thanks