×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Jan 2010
    Posts
    52

    File Concatenation

    Hey guys,

    I'm developing a J2ME MIDlet for a Nokia S40 device. The MIDlet writes messages to a log file that is located on the device's file system. I don't want the size of this log file to be over lets say 1MB. Can anyone give me a code snippet I can put in the MIDlet's startup function that checks the the log file's size isn't greater than 1MB, and if it is, it concatenates it to a 1MB size?

    Thanks!

  2. #2
    Regular Contributor
    Join Date
    Jul 2008
    Location
    Faridabad(Delhi NCR)
    Posts
    343

    Re: File Concatenation

    Hi
    Are you want to split your file or you want that your want to create only one file but it should be less then 1MB. Please tell me how you are writing file.There is an command from which you can get the file size. so when you are writing file just break the loop if you are writing your file inside

    While(is.read()){
    }

    like this but please tell me firstly how you are writing file
    Anshu Chauhan
    J2me Developer

  3. #3
    Regular Contributor
    Join Date
    Mar 2007
    Location
    "On a b'ful lil palnet called EARTH belongs wid Galaxy named MilkyWay in Universe"
    Posts
    402

    Re: File Concatenation

    Quote Originally Posted by giaviv View Post
    Hey guys,

    I'm developing a J2ME MIDlet for a Nokia S40 device. The MIDlet writes messages to a log file that is located on the device's file system. I don't want the size of this log file to be over lets say 1MB. Can anyone give me a code snippet I can put in the MIDlet's startup function that checks the the log file's size isn't greater than 1MB, and if it is, it concatenates it to a 1MB size?

    Thanks!
    That's pretty simple and it can be done using the in built method of the File Connection API.Here you go:
    public long fileSize()
    throws java.io.IOException
    Determines the size of a file on the file system. The size of a file always represents the number of bytes contained in the file; there is no pre-allocated but empty space in a file. Users should perform an explicit flush() on any open output streams to the file prior to invoking this method to ensure accurate results.
    Returns:
    The size in bytes of the selected file, or -1 if the file does not exist or is not accessible.
    Throws:
    java.io.IOException - if the method is invoked on a directory.
    java.lang.SecurityException - if the security of the application does not have read access for the file.
    IllegalModeException - if the application does have read access to the file but has opened the connection in Connector.WRITE mode.
    ConnectionClosedException - if the connection is closed.
    Please mark that the above will return you the number of bytes in the file and hence as soon you wanna write the data in the file you invoke the same method and then divert the flow of your code.
    ===With Symbian===
    "Something Has Survived..!!!"

  4. #4
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: File Concatenation

    Hey Nitin.. Welcome back! Now you are into Java ? Does it mean that you are changing your focus from Qt (cute) ? All the best!

    @ giaviv : Just to add what Nitin Suggested; It would be good if you can compress the file while writing itself; like removing unwanted line breaks and spaces (also can look for a better compression algorithm), so that your app dont have the overhead to check it at a later point of time and compress it.

    Regards
    Gopal

Similar Threads

  1. String concatenation
    By manubemanu in forum Symbian
    Replies: 3
    Last Post: 2010-06-14, 15:52
  2. sms concatenation help
    By ruggish in forum General Messaging
    Replies: 3
    Last Post: 2004-09-10, 06:16
  3. 7-Bit Concatenation
    By spborbe in forum General Messaging
    Replies: 3
    Last Post: 2003-11-15, 07:11
  4. Concatenation flag
    By h2ooo in forum General Messaging
    Replies: 1
    Last Post: 2003-06-11, 13:08
  5. TDMA Concatenation
    By Nokia_Archive in forum General Messaging
    Replies: 1
    Last Post: 2002-05-23, 12:37

Posting Permissions

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