Java.io.File extension proposal

Hi, i have made an extension to java.io.File that right now lets you find out free disk space, used disk space and all mounted volumes.
I currently have code for linux only and i'm looking for help porting it to win32.
I put up a project page on http://mog.se/mogio.html
I'm aware of projects like JConfig and i'm not interested in it because of their license and their totally different API. se.mog.io.File extends File to work just like a normal java.io.File with some additional methods, in the spirit of java.io.File. :)
Any help in coding or feedback is appreciated, be it negative or positive. :)
/mog

listMounts() is intended to be like listRoots() but
show mounted volumes below the root.I thought about this too, but the mounts themselves wouldn't really be `below' the root as one could mount anywhere in the Unix fs tree. Now wouldn't the mounts actually be the roots in Winblows?
What would be nice would be some metric given any given java.io.File directory, such as I may know that the directory has a metric that lets me know the quality of the disk such as a good SCSI array for persistent storage vs. a single IDE for a scratch or temp dir.
I'm not aware of AS/400 or any anti-OS pro-JVM devices
but would java.io.File be applicable there anyway?File would be of course applicable for the IFS on AS/400, but it's been a LONG time (read deploying on 1.1 V4R?) since I've used the 400 and I don't have detailed knowledge on storage management there, so I may need to defer to someone on that architecture to know about mounts, etc.
There is however a really small group of people who feel that all storage should be secondary or auxillary storage (I'm partially one of them) and when you need to access data, you peek at a memory location (to which of course you would have access) or pointer|reference|et al. The OS is then responsible for intelligently paging that data in/out of primary memory for access, like a super-mega-MM, or conversely just read from the secondary itself, either way the VM wouldn't care. We're a ways away from an OS/JVM combo like this though and I feel it will be a long time until we get rid of the traditional thought process of filesystems.

Similar Messages

  • Trying to write data to a text file using java.io.File

    I am trying to create a text file and write data to it by using java.io.File and . I am using JDeveloper 10.1.3.2.0. When I try run the program I get a java.lang.NullPointerException error. Here is the snippet of code that I believe is calling the class that's causing the problem:
    String fpath = "/test.html";
    FileOutputStream out = new FileOutputStream(fpath);
    PrintStream pout = new PrintStream(out);
    Do I need to add additional locations for source files or am I doing something wrong? Any suggestions would be appreciated.
    Thank you.

    Hi dhartle,
    May be that can help:
    * Class assuming handling logs and connections to the Oracle database
    * @author Fabre tristan
    * @version 1.0 03/12/07
    public class Log {
        private String fileName;
         * Constructor for the log
        public Log(String name) {
            fileName = name;
         * Write a new line into a log from the line passed as parameter and the system date
         * @param   line    The line to write into the log
        public void lineWriter(String line) {
            try {
                FileWriter f = new FileWriter(fileName, true);
                BufferedWriter bf = new BufferedWriter(f);
                Calendar c = Calendar.getInstance();
                Date now = c.getTime();
                String dateLog =
                    DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM,
                                                   Locale.FRANCE).format(now);
                bf.write("[" + dateLog + "] :" + line);
                bf.newLine();
                bf.close();
            } catch (IOException e) {
                System.out.println(e.getMessage());
         * Write a new line into a log from the line passed as parameter,
         * an header and the system date
         * @param   header  The header to write into the log
         * @param   info    The line to write into the log
        public void lineWriter(String header, String info) {
            lineWriter(header + " > " + info);
         * Write a new long number as line into a log from the line 
         * passed as parameter, an header and the system date
         * @param   header  The header to write into the log
         * @param   info    The line to write into the log
        public void lineWriter(String header, Long info) {
            lineWriter(header + " > " + info);
         * Enable to create folders needed to correspond with the path proposed
         * @param   location    The path into which writing the log
         * @param   name        The name for the new log
         * @return  Log         Return a new log corresponding to the proposed location
        public static Log myLogCreation(String location, String name) {
            boolean exists = (new File(location)).exists();
            if (!exists) {
                (new File(location)).mkdirs();
            Log myLog = new Log(location + name);
            return myLog;
         * Enable to create the connection to the DB
         * @return  Connection  Return a new connection to the Oracle database
        public static Connection oracleConnectionCreation() throws Exception {
            // Register the Oracle JDBC driver
            DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
            //connecting to the DB
            Connection conn =
                DriverManager.getConnection("jdbc:oracle:thin:@myComputerIP:1521:myDB","user", "password");
            return conn;
         * This main is used for testing purposes
        public static void main(String[] args) {
            Log myLog =
                Log.myLogCreation("c:/Migration Logs/", "Test_LinksToMethod.log");
            String directory = "E:\\Blob\\Enalapril_LC-MS%MS_MS%MS_Solid Phase Extraction_Plasma_Enalaprilat_ERROR_BLOB_test";
            myLog.lineWriter(directory);
            System.out.println(directory);
    [pre]
    This class contained some other functions i've deleted, but i think it still works.
    That enables to create a log (.txt file) that you can fill line by line.
    Each line start by the current system date. This class was used in swing application, but could work in a web app.
    Regards,
    Tif                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Changing the file extension by entering a "?" in JFileChooser

    Hi,
    I've encountered a weird thing in JFileChooser. If you open the chooser, type at least one "?" in the field for the filename and then hit the approve button, the file extension will change to the text you entered as the filename.
    To reproduce this problem, simply launch the JWSFileChooserDemo hit the "Open a File..."-button and as the filename enter something like "?deadbeef". Now click the open button and you will see that the file extension changes to "?deadbeef".
    This is a really strange behaviour in my opinion.
    I'm using Windows 7 with java 6u16, but the issue is the same on windows xp sp3. Perhaps on linux too. I'll give it a try as soon as I can.
    Has anyone else encountered that problem?
    Best regards
    Edited by: Wurstsalat on Mar 23, 2010 10:30 AM

    To reproduce this problemThis is not a problem but rather a feature. I did not know of this till now. Thanks for informing.
    As Kevin pointed out this is related to filtering of files.
    ?deadbeefThis will match all the files which start with any letter followed by "deadbeef". So, ? is a wildcard meaning any one character. Other wildcard can be *, which means any number of characters. Try this:
    *.txt
    a*.txt
    *.jp*g
    ??.txt I don't know other wildcards...
    Thanks!

  • Can you create file extensions?

    Does anyone know if u can create file extensions to read and write from using java? If so can u tell me how or reccomend something that might help teach me?
    Thanks
    Mike

    yeah, i'm pretty sure you can use the java FileInput and printStream classes to make a new file, i mean as long as the file contains a text base, the extension really doesn't matter

  • CFDirectory Sort By File Extension

    Does anyone know how to sort files in a CFDirectory by File
    Extension (.gif, .jpg... etc)?

    i think the only way to do it with just cf will be:
    1) run cfdirectory to get the dir structure
    2) loop through the result
    3) populate a temp query with values from cfdirectory query
    and an extra
    field with value of #right(cfdirectoryquery.name, 3)#
    4) run QoQ on the temp q with ORDER BY on the extra field
    other than that, look into java - it has ways to work with
    directories/files which are a lot more comprehensive than
    CF's...
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com

  • Change the file extension

    Hello everybody,
    I want to change the file extension using java. For example the file is xyz.dat it will change to xyz.data. Is there any method which will do this task.
    smh

    http://javaalmanac.com/egs/java.io/RenameFile.html

  • Unable to change File Type for specific file extensions

    Under Preferences->File Types different file extensions are assigned a file type e.g. The file extension .pkb is assigned the file type of PL/SQL. The file type of PL/SQL then opens the Code editor.
    I have a user who would prefer to open .pkb files in the SQL Worksheet editor but I am unable to change the file type to SQL Script as the option is greyed out.
    How do I change the File Type for these extensions? Is there a preferences file I need to change?
    Version: 3.2.20.09
    Thanks for your help.

    Hi,
    There is no preference but it turns out you can manually edit one of the preferences.xml files to force PL/SQL types to use the SQL worksheet editor. For SQL Developer 3.2.20.09.87 that file is system3.2.20.09.87\o.sqldeveloper.11.2.0.9.87\preferences.xml and will be located (on Windows 7, for example) in directory C:\Users\<userid>\AppData\Roaming\SQL Developer
    No guarantee this will work in future versions of the product, but for now you can add the following two xml blocks...
    For example, for .pls, add to <extensionToContentTypeMap ...>
                <Item>
                   <Key>.pls</Key>
                   <Value>TEXT</Value>
                </Item>
    and <userExtensionList>
                <Item>
                   <docClassName>oracle.ide.db.model.SqlNode</docClassName>
                   <userExtensions class="java.util.ArrayList">
                      <Item class="oracle.ide.config.DocumentExtensions$ExtInfo">
                         <extension>.pls</extension>
                         <locked>false</locked>
                      </Item>
                   </userExtensions>
                </Item> I researched this a while back after reading through some forum thread where someone claimed the PL/SQL file extensions got opened in the SQL editor in his environment, but without stating any specific release information. Possibly it worked for him then due to different product behavior (whether intentional or a bug), or perhaps even due to the technique described above.
    Regards,
    Gary
    SQL Developer Team

  • FileDialog (filtering for certain file extensions)

    I have used JFileChooser in the past and was modifying my code to use FileDialog instead as it looks better, looks like the one used by every other Windows program and takes less code to get the job done. My
    question is how to filter for certain file extensions in FileDialog as you can in JFileChooser. I cannot seem to figure out how to, so any help would be highly appreciated. Thank you.
    P.S. Also if you know how to turn off all files like you can in JFileChooser, that would also be extremely helpful.

    Go to the JFileChooser tutorial at http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html and skip to the section entitled "Filtering the List of Files". That sounds like it should answer your question.

  • File extension getter

    Is there a method in the API that will get the file extension off of a file name so that I can filter out certain ones. I'm providing an example just in case I'm using the wrong terminology, which could be why I'm having trouble finding it in the API.
    ex: MyProgram.java
    and then I only want to print it to the screen if it has the java extension.

    "Extension" isn't a cross-platform concept, so Java
    hasn't gone out of its way to support it. Follow
    walken16's suggestion of writing your own.
    (It's trickier than you might think. Watch out for
    edge cases like ".net" and "Finally." and
    "too.many.dots".)Could you clarify what you mean by: '...........cases like ".net".................'
    I had always assumed that an extension was an extension was an extension......
    I only program on windows............
    I normally use this in my code:
         Gets The Extension.
         @param     f     A File To get The Extension of
         @return     The Extension part of the FileName.
         public static String getExtension( File f )
              String fileName;
              int index;
              int L;
              if( f != null )
                   fileName = f.getName();
                   L = fileName.length();
                   index = fileName.lastIndexOf('.');
                   if( (index > 0) && (index < (L - 1)) )
                        return fileName.substring( index + 1 ).toLowerCase();
              return null;
         }and just assumed that if somone renamed a file as blah.exe.old they meant it, and that Windows only ever cares about the .old part.
    Am I missing something?
    Not that anyone would ever get to run my programs, being just a hobbyist, still I like to think I'm learning the right way...........

  • Application Design,Java Read Files,Merging Files,Outresults

    Read all files from a folder in the same directory
    Files with the same name but different extension
    On .txt extensions,count the number of words,the start and end offset of each word,output into a textfiles
    Merge a1,a2,ann,rel(other file extensions),on read each line,and store it into a data-structure
    Join results of 3,4 and output into a new folder <previousfolder>_result
    What are the operations that I can use to achieve this with java?
    How can I achieve this with java?

    Welcome to the forum!
    When you post your class assignments you should provide the class name, teacher name, textbook used and the exact instructions for the lesson as presented by your teacher.
    >
    Read all files from a folder in the same directory
    Files with the same name but different extension
    On .txt extensions,count the number of words,the start and end offset of each word,output into a textfiles
    Merge a1,a2,ann,rel(other file extensions),on read each line,and store it into a data-structure
    Join results of 3,4 and output into a new folder <previousfolder>_result
    What are the operations that I can use to achieve this with java?
    How can I achieve this with java?
    >
    Have you covered all of those concepts in your class?
    Did you ask you instructor to explain any of the steps you did not understand?
    Have you written, compiled and run any Java classes at all yet?
    Post the code you have written so far, explain what it does and what it does wrong and you will get advice about how to find and fix the problem.
    Break the problem into pieces. Start by writing code that
    >
    Read all files from a folder in the same directory
    Files with the same name but different extension
    >
    Post the code and the results it gives you.
    Good luck with your assignment. Remember, the teacher is there to help you if you get stuck.

  • What is file extension .class?

    I am new to java and want to know what the file extension .class is and how do I open and edit a file with this extension?

    .class files are created by the compiler from .java file, which is your code... if you're new to java, you probably don't want to open and edit your .class files. If you want to make changes to your program, open the .java and recompile.

  • What is java .jpr file type?

    What is java .jpr file type?

    jetq wrote:
    What is java .jpr file type?http://www.fileinfo.com/extension/jpr
    does that help?

  • JFileChooser - unable to disable file extension display

    Hello All,
    I'm trying to use JFileChooser in my Swing application with following conditions:
    1) Only xml files will be displayed
    2) the file names shall NOT be shown with their extension. That is - listing of XML files shall occur only by their name - "abc" and not "abc.xml"
    I've already acheived the 1st objective.
    However, I am unable to block the display of file extension when JFileChooser opens.
    Has the display of file extension got to do with Operating System feature?
    Is there a way in Java Swings to curb such a a display?
    Thanks

    Implement your own FileView class (you can extend any of the L&F FileViews), then pass the object to:
    JFileChooser::setFileView(FileView fileView);
    Hint: The method you want to override is getName(File file).
    Regards,
    Marcin

  • Opening BATCH file through custom file extension

    I have a situation where I've created my own filetype (.gme) to open my main java file. Each filetype has a corresponding ID which tells the application what instance of it to load. I want the file type to open a batch file which will in turn open the application. Is there code that I can give a custom file extension to open a batch file?

    Check the permissions of that batch file.
    It should be executable for the PI user (<sid>adm in Unix)
    Regards
    Stefan

  • What is going on here? .txt file extension

    I apologize for asking this question, but at the risk of sounding completely fried, here goes...
    I've saved my program in Notepad with the .java file extension, but when I run dir command in DOS, the file ends with the .txt file extension (i.e. HelloWorld.java.txt). Could someone give me a clue how to keep Notepad from automatically ending my program with this .txt file extension.? I've have not encountered this problem before.
    Thanks

    Thanks for your help.
    I figured out that I didn't have the .java file extension defined in Windows. Because Notepad didn't recognize .java as a valid file type, it would automatically assign the .txt after my program files.
    To fix this...
    1.) Start Explorer
    2.) Select the View...Options... file menu
    3.) Click on the File Types tab
    4.) Click on the New Type... button
    5.) Enter the following in the Description of type: edit box: Java Files
    6.) Enter the following in the Associated extension edit box: .java
    7.) Click OK
    8.) Click OK
    Thanks for your responses.
    CJ

Maybe you are looking for