Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2013
    Posts
    5
    Rep Power
    0

    Default How to create a completely new file?

    Hi all,

    Does anyone know how to create a totally brand new file.type that is only readable by a specific Java program?

    For example:
    Microsoft word can read .docx files (sure there are others).
    Microsoft word cannot read .3dsm (not sure what file type 3dsmax uses, but Word can't read it).

    What I want:
    My Java Program can read .xxx files. Since .xxx will have a unique storing format,
    No other Program can read .xxx files.

    So my question is, how can I create a totally new kind of file, and how do I program it in java.
    I googled it, but I only find how to make .txt files which is not what I want.

    Please don't ask what I'm making, I'm just trying to learn for a future big project.

    Thanks in advance!

  2. #2
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    298
    Rep Power
    4

    Default Re: How to create a completely new file?

    Try to use that example you have from Google. Just change your extension form .txt to .xxx inside your code..

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: How to create a completely new file?

    Quote Originally Posted by milovan View Post
    Try to use that example you have from Google. Just change your extension form .txt to .xxx inside your code..
    Well sort of. If the example in Google writes to a text file, then no matter what you change the extension to, it will still be a text file. The key will be to not write out text or chars with a Writer or PrintStream but rather to write bits and bytes in some way that makes sense to you where you can reverse the process and read in the data. You will likely need to create some type of file header that holds the "meta" information of the file and have this filed by the file data itself. Another option is to encrypt the file.

  4. #4
    Join Date
    Jan 2013
    Posts
    5
    Rep Power
    0

    Default Re: How to create a completely new file?

    Agreed, renaming a text file is still a text filed. I think encrypting is the way to go.

    Another approach I could do is some kind of library of items, where the items are locked up, and the only way to access the library is through the program. However, this would require a creating of the library as a folder. I want to make a program that can store images, but I want the images to be protected so that no one edits them, so if I could make a library that store's the images data, but additionally requires some string or code to access it, then that should also do the trick.

    Still though, does anyone have any idea how to make one? Not entirely sure if its doable via java, but since java directs data then why not? >.>

  5. #5
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    298
    Rep Power
    4

    Default Re: How to create a completely new file?

    Quote Originally Posted by Fubarable View Post
    Well sort of.
    ;-)

    Depending on his needs and requirements he might find serialization as sufficient solution..
    Last edited by milovan; 01-27-2013 at 11:43 PM.

Similar Threads

  1. Help plz: not completely working JAR
    By linkingabo in forum NetBeans
    Replies: 6
    Last Post: 01-28-2012, 04:32 AM
  2. completely new
    By battosai16 in forum New To Java
    Replies: 1
    Last Post: 08-05-2010, 07:43 PM
  3. Replies: 1
    Last Post: 08-04-2010, 03:24 PM
  4. Replies: 1
    Last Post: 03-31-2010, 08:04 PM
  5. I am completely stuck
    By jpnym15 in forum New To Java
    Replies: 2
    Last Post: 11-14-2007, 06:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •