User Profile

Collapse

Profile Sidebar

Collapse
KWSW
KWSW
Last Activity: Feb 12 '08, 05:09 AM
Joined: May 22 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • thanks again... it works... one last qn(hopefully).. .

    I know i can use

    for(Int i : map.keyset())

    to go through the whole map, but if I want to just take out the first ten, is there another type of for loop to do it?...
    See more | Go to post

    Leave a comment:


  • ok will try it out...

    btw it will be from the lowest to highest right? Is there anyway to get from the back or sort it the other way around since I need the highest frequency?...
    See more | Go to post

    Leave a comment:


  • KWSW
    started a topic Sorrting Elements In Map Collection Based On Value
    in Java

    Sorrting Elements In Map Collection Based On Value

    I need to sort out based on frequency certain events that happen.

    I use a map with the event name as the key(String) and the frequency(Integ er) as the value and every time an event happens.

    I have no problems with the part of adding and updating but am abit stuck at the sorting part as I need to display the events sorted from higest frequency to lowest.

    At first I was thinking of putting them into another...
    See more | Go to post

  • KWSW
    replied to Digital Signature with DSA
    in Java
    I did a bit of a test and found out the lengths varies abit from 46 to 48 even though i was signing the same thing.

    Decided to write the length of the signature to at the start of the file but am still trying to find out if there is a better way...
    See more | Go to post

    Leave a comment:


  • KWSW
    started a topic Digital Signature with DSA
    in Java

    Digital Signature with DSA

    Got a question:

    I managed to generate a key pair with DSA and have no problems signing and verifying with them.

    But I need to attach the signature to the start of a file and have the receiver receive the file, check the signature before processing the rest of the file.

    Is there a fixed length for the key size so that the receiver knows how many of the bytes in the start of the file is for the signature?...
    See more | Go to post

  • KWSW
    started a topic Java AVI Player
    in Java

    Java AVI Player

    Got an assigment where I need to create a plugin for any media player that plays AVI using my current java program which does some processing to the AVI file.

    Of cos I need to modify my program into a plugin but was wondering if there are any media player out on the web that can use a java program as a plugin.

    Thanks.
    See more | Go to post

  • KWSW
    replied to Handling Blocks of Bytes
    in Java
    ok one of those weird days... now its works... -_-'''

    anyway thanks again for the help :)
    See more | Go to post

    Leave a comment:


  • KWSW
    replied to Handling Blocks of Bytes
    in Java
    i have a problem becos while the file size is the same, the file isnt...

    I solved the part about the last byte[] being smaller than the block size so my files are the same size now. But they are not the same file. As in if its a picture file, the output will be corrupted. But it works fine with text...
    See more | Go to post

    Leave a comment:


  • KWSW
    replied to Handling Blocks of Bytes
    in Java
    what i need to do is to read in a file, chop it up into blocks of a certain size, do some checking to the blocks and write them out if they pass the checks.

    What I am trying to do now is to make sure that what i read in as blocks are written out properly so the file is still the same....
    See more | Go to post

    Leave a comment:


  • KWSW
    replied to Handling Blocks of Bytes
    in Java
    it doesn't read the next set of bytes automatically?...
    See more | Go to post

    Leave a comment:


  • KWSW
    replied to Handling Blocks of Bytes
    in Java
    but now i cant seem to write properly... lol... i check the output file and its the same size as the input file...

    my codes:

    Code:
    ArrayList<byte[]> al = new ArrayList<byte[]>();
    byte[] b = new byte[bSize]; 
    
    FileInputStream fIn = new FileInputStream(inFile);
    BufferedInputStream in = new BufferedInputStream(fIn);
    ...
    See more | Go to post

    Leave a comment:


  • KWSW
    replied to Handling Blocks of Bytes
    in Java
    oh ok... haha... got a bit confused just now...

    ok so lets say i have a file size of 10000 bytes and a block size of 100 bytes.

    so i would have 100 byte[100] in the arraylist....
    See more | Go to post

    Leave a comment:


  • KWSW
    replied to Handling Blocks of Bytes
    in Java
    got another qn though... i would need an integer to define the size of the byte[] array and am worried that if the file is too big, the integer data type cant fit it.

    Wanted to use long but the byte[] can only take in integer. Is there a way around it or the integer data type should be big enough.

    I would assume a 200~300 mb file would be the biggest I ever have to handle.
    See more | Go to post

    Leave a comment:


  • KWSW
    replied to Handling Blocks of Bytes
    in Java
    oh btw... just to confirm, when i read in the whole file at the first go before chopping them up into blocks, Byte[19] would refer to the 20th byte in the file right?
    See more | Go to post

    Leave a comment:


  • KWSW
    replied to Handling Blocks of Bytes
    in Java
    ok thanks will give it a try later :)...
    See more | Go to post

    Leave a comment:


  • KWSW
    started a topic Handling Blocks of Bytes
    in Java

    Handling Blocks of Bytes

    Just a question on handling "Byte[]" in java.

    I have to read in a file of any type and chop it up into blocks for processing later on.

    Was wondering if I got do a Byte[][] to keep the Byte[] in an array or would something else be a better way of doing it as I do now know how many elements the array of Byte[] can hold as the file might be huge and the blocks might be small.

    Thanks. :)
    See more | Go to post

  • KWSW
    replied to Reading & Writting Binary File
    in Java
    ok nvm... solved it :)
    See more | Go to post

    Leave a comment:


  • KWSW
    started a topic Reading & Writting Binary File
    in Java

    Reading & Writting Binary File

    Got a question about reading and writing binary files.

    I know that to write a value(integer) to a binary file I can use the fileoutputstrea m to do it.
    Code:
    try 
    {
            // Create an output stream to the file.
            FileOutputStream file_output = new FileOutputStream (outFile);                                                              
    
            //for(int i = 0; i < cInt.length;
    ...
    See more | Go to post

  • KWSW
    replied to binary string to integer
    in Java
    ok thanks, will take a look :)...
    See more | Go to post

    Leave a comment:


  • KWSW
    started a topic binary string to integer
    in Java

    binary string to integer

    Another question to ask about built in java functions.

    I know that there is a Integer.toBinar yString function where I can get the binary value of an integer in a string representation.

    Example : from 107 i get "1101011"

    Question would be, is there a function where I can convert back from string to integer. Like int i = functionName("1 101011") where i will contain 107.

    ...
    See more | Go to post
No activity results to display
Show More
Working...