find « directory « Java I/O Q&A





1. What is the best way to find the users home directory in Java?    stackoverflow.com

The difficulty is that it should be cross platform. Windows 2000, XP, Vista, OSX, Linux, other unix variants. I am looking for a snippet of code that can accomplish this for ...

2. How can I find out if a File is a file or directory if it does not exist?    stackoverflow.com

File.isFile() and File.isDirectory() both return false not only when the File is not the specified type, but also when the File itself does not exist on the filesystem. How can ...

3. java "cannot find symbol" - how to import a file in the same directory?    stackoverflow.com

I have two java files in a directory, neither of them are in a package. I want one of them to be able to reference the other. What is the right ...

4. What's the best way to find the home directory of an arbitrary user in Java?    stackoverflow.com

What's the best way to find the home directory of an arbitrary user (not necessarily the one running the program) on a Unix-like system, given their username? I'm looking to do something ...

5. Java library function to find shadow file in different directory    stackoverflow.com

I often have code where I loop over a directory (including subdirectories) and need to move / copy the file to a different directory. What I find tedious is the process ...

6. Java can't find local files after calling PrinterJob.getPrinterJob().defaultPage()    stackoverflow.com

I'm really stumped on this issue. I have a problem where Java can't find files in the local directory after calling the method PrinterJob.getPrinterJob().defaultPage(); In fact I've boiled it down to the ...

7. Java find start of file name and extension    stackoverflow.com

HI, I have almost solved this but have now got stuck! What I need to do is look in a folder say..

String path = C://;
I then need a loop to see how ...

8. find same file with in many directories in hierarchical directories in java    stackoverflow.com

I am trying to get a report file which is generated for many applications and stored in directories. But i am not able to get every report when i ...

9. how to find out the size of file and directory in java without creating the object?    stackoverflow.com

First please dont overlook because you might think it as common question, this is not. I know how to find out size of file and directory using file.length and





10. Using Java find installation directory of an application?    stackoverflow.com

How do I find installation directory of OpenOffice using Java Code? I want to run it as a service when a user uses my application.

11. Find first file in directory with Java    stackoverflow.com

I have some sort of batch program that should pick up a file from a directory and process it. Since this program is supposed to:

  • run on JDK 5,
  • be small (no external libraries)
  • and ...

12. Getting IOException, cant find any reason    stackoverflow.com

I tried to read rgb of specific pixels however i was getting IOException.
I couldnt find any reson so yet i tried to run program from this site link ...

13. java.io.IOException: The system cannot find the path specified    stackoverflow.com

I am trying to open a file i just created in my code (so i am sure that the file exists) The code is like this:

File file = new File(filename);
file.createNewFile();
BufferedWriter bw = ...

15. Finding a folder or a file    coderanch.com

Thanks Harold A. Gimnez I ended up

code:
 /** ------------------------------------------------------------ findFolder find a specific folder in a path? ------------------------------------------------------------ input: path:Starting path to search for folder folder:The folder name to process. @return the full path to the specified folder w/o folder ------------------------------------------------------------ */ public String findFolder( String path, String folder) { String returnValue = null; File f ...

16. Finding the main class path    coderanch.com

Hi everybody, Preparing my SCD assignment, I tried to find out a way to know the start directory of my application (I mean the directory my main class is in). Surprise ! It seems (confirmed by other threads on this forum) that there is no simple method to get that basic information in Java (something as simple as the well-known Delphi ...





17. File object can't find directory    coderanch.com

I am actually having 2 issues which might or might not be related to each other. I have a Java class in /dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dir10/dir11/dir12 that needs to write to a file located in /dir1/dir2/dir3/dir4/dir5/dirA/dirB So I'm starting out with: File logFile = new File("/dir1/dir2/dir3/dir4/dir5/dirA/dirB/test.txt"); then checking the value of logFile.exists() (The file should always exist because I created it manually prior to ...

18. Finding Folders    coderanch.com

Hi all , I have to find whether a particular folder exists or not in my local machine , if it presents then i need to find out in which drive it presents ? I wrote a code using Java File system . But it displays only the directories from C: drive. So if i give any other folder name which ...

19. Need to find executable from path    coderanch.com

Hi all, My application allows the user to specify an executable to be launched on request. This is working ok when the user specifies the complete path to the executable, but I now have an additional requirement: if the complete path is not specified, find the executable in the system PATH. I'm not finding anything in the APIs that lets me ...

21. how to find the intermediate directory    coderanch.com

hi, I want to get a class file which is stored in one location like "C:/m1/m2/m3/m4/m5/.../m10/stcm.class" and i stord my java source file in another location called "C:/m1/m2/m3/m3/StringComparison/m4/m5.../m10/stcm.java".I want to copy the class file and source file to other location called " C:/m1/m2/". This is my case and know the location of class file exactly and in case of java file ...

22. Finding the filenames of all the files in a directory    coderanch.com

There are two specific methods for listing the files in a directory. They are both in the class File. list() and listFiles() list() returns an array of Strings. listFiles() returns an array of File objects. There are also flavors of these two that incorporate filters for filenames. ------------------ Jason R. Kretzer Software Engineer

23. to find the home directory in java    coderanch.com

24. How to find a string in multiple files in a directory.    coderanch.com

I can find a string in specific file when the file is in the same directory as the .class file. But what I need to do is find a string that exists in multiple files in a directory and it's subdirectories. I know I can "grep" the string and that works fine, but I need to get rid of the "grep" ...

25. Find the path of a file    coderanch.com

26. Finding path of a file    coderanch.com

27. System cannot find the path specified    coderanch.com

Two reasons: (1) In windows, a mapped network drive is per user only -> if you see the network path under R: doesn't mean that the service account running servlet container can see it on R: (2) Anyway for security reasons, the default window service account won't be able to access network drives. Hence even if you use the full network ...

28. find file with * on the path    java-forums.org

Hello I need to check if there are files in path that in the the format that might contain "*" . ( for example /tmp/*/1224/*.doc mathing path can be /tmp/dir1/1224/abcd.doc in linux is very simple ( set files = "/tmp/*/1224/*.doc" ) How can I do it in java without start searching for "*" and buliding lops?

29. finding files and folders    forums.oracle.com

Basically what I want is small search program kind of like the windows search program but a little more advanced, I want to be able to search for a varitey of files and when these are found copy them to a new file. 1. What code can I use to get file-names from a windows os. 2. If the directory that ...

30. Finding files, path    forums.oracle.com

31. Problem linking classes in the same directory "cannot find symbol...class"    forums.oracle.com

Hi, I don't know what's happened, I think something is up with my Java installation, hopefully you can help me fix it To provide a trivial example, I've got 2 classes, and one references the other. eg. public class MyClass1{ public static void main(String[] args){ MyClass2 secondClass = new MyClass2(); } } These classes are in the same folder on my ...

32. How do I find where the Apache home directory is?    forums.oracle.com

I am working with a server on which someone else installed Apache. In fact, they have both Apache 1.3 and Apache 2.0 on it. Only Apache 2.0 is active. I don't know what they used to install it or where Apache came from. The people who installed it cannot be reached. How do I find out which directory is Apache_home? At ...

33. Cannot find symbol: Classes in same directory    forums.oracle.com

Am working through exercises in Java text-book and have come across a problem in compiling which I cannot seem to shift and is not covered by the book. I have two source files; Point.java which plots a point on two axes and includes some methods, and Line.java which uses objects of class Point to create Line objects on same axes. Point.java ...

34. Finding a file using File path (Folder name) inside a Java Project    forums.oracle.com

Hi Everyone, Am sorry for the cross-post. I actually meant it to be posted in this Forum. I would really appreciate some tips. Scenario: I have a java project "Generator": -> It has its .java files in the branch -> It has a folder in the branch called "SourceFiles" (here I have C++ files ... the header files.) -> This header ...

35. Find a specific pattern in MULTIPLE files in same directory    forums.oracle.com

This code searches a file for comments. I am searching for my pattern. Could you please tell me how to design the for loop. File aDirectory = new File("C:/Dir1/abc/"); //here is my directory which has 50 text files with some pattern String[] filesInDir = aDirectory.list(); //i get the file names here in string format..maybe use them for filesInDir.length function for the ...

36. Issue related finding a file in a directory    forums.oracle.com

Hi I am trying to find a file from a directory and print it on screen using only first half of the file name. like I have files you_are_best.pdf,you_are_geneious.pdf, we_are_best.pdf. Now I need to find the pdf from the directory having name you_are. can any one help me in solving this issue.

37. Finding application installation directory    forums.oracle.com

Hello everyone, I have a question regarding how to find the directory where I have installed my application, and from where my application will be launched? For example, lets say that my java application has a executable jar file called "ToolLaunch.jar". When someone installs the application in a folder, the jar file is placed under "SomeTool" folder. Lets say the directory ...

38. Need help in finding Duplicates in file or folders    forums.oracle.com

Hi LukeFoss, With due respect, I wanna say I dont believe in cheating. I am not gonna show my teacher or anybody else that I did something like this. I was just trying to learn something like that for finding out my own pc's duplicate files. I am interested in learning such thing not for anything else. If anyone could give ...

39. Find filenames in directory    forums.oracle.com

Is there some way to parse a specific directory and get the names of the files in that directory? I have a folder named FILES that will contain *.xls files. My intent is to have the program parse the FILES directory and display all of the file names in a JOptionPane.showInputDialog() method. I know you can use JFileChooser to select files ...

41. Finding the exact path of a file using a Java program    forums.oracle.com

actually i m trying to write a program which will take a name of a file or a directory from the console and it should give the entire path of that file or directory and this file need not be stored in the path of the main class.....It can be stored in any drives of my PC....

42. Find working directory of a class    forums.oracle.com

The thing I want is how can I know the working directory of a running class? Classes do not run, threads do. The directory you are describing is where the class loader found the .class file. Having said that, I do not have a solution for you; however, you might find something if you look at the class loader classes. On ...

44. how to find directory size    forums.oracle.com