4
votes
1answer
77 views

Java loop and shifting

To cut a long story short, I'm trying to generate Huffman codes from a canonical Huffman list. Essentially, the following two loops should run, and generate a binary string. The code is: for (int i ...
-6
votes
1answer
45 views

How to write a method that parses a decimal number into a binary number as a string [closed]

I have no clue how to start except I have my header. public static String convertDecimalToBinary(int value) That is all
0
votes
1answer
55 views

Binary XML file line #2: Error inflating class

I know similar questions like this has been answered but I seem to have done what the tutorial suggested and reading from other posts but still I get the Inflator error. Not sure what I am doing ...
1
vote
1answer
25 views

how to read the given binary struct using java?

I'm trying to decode and read binary data sent from a device, I need to extract a decimal number which is inside the binary structure. this is the structure detail: (2) Synchronization message format ...
0
votes
2answers
58 views

Binary search algorithm does not work properly - Java

I want to make my own binary search algorithm to search ArrayList of 1 000 000 elements. I decided to do the search with do-while loop. I am aware I could use while() loop. But when I run it, it takes ...
0
votes
2answers
27 views

Problems in binary tree traversal

I am trying to implement a binary search tree with In order traversal. I am trying to print a series of numbers after each other to test it. It seems that it is sorting well, however it is printing ...
0
votes
1answer
89 views

Trying to invert binary numbers in java

I want to invert binary representation of a number. The method in the program receives a 6 character hex color code via the parameter col. It should convert this value to its binary counterpart(e.g. ...
0
votes
1answer
121 views

How to compress a string of 0s and 1s in java

I am doing Huffman Coding right now and I ran into this bump in the road. I have pretty much everything done but this one part. My main issue right now is I am not sure how to store my binary string ...
0
votes
3answers
56 views

Convert value to binary and then flip all the bits in Java

First of all i receive a hex color code from a parameter 'col'. I then convert this value to the binary equivalent and then need to flip all the bits and convert it back to the hex value. Then the hex ...
0
votes
2answers
48 views

How can I do binary search in java ArrayList<Long>?

I am trying to make binary search in ArrayList, but the binarySearch method does not work for Long, as well as Double and Float. My code is import java.util.*; public class BinarySearchInArrayList{ ...
0
votes
2answers
22 views

How to make String Print

I can not figure out why when I run the program it is does not print strings. Instead, it will print out numbers. public class Coulter_BST_String { public static void main(String[] args) { ...
0
votes
2answers
63 views

binary Expression tree, emptyStackException (java)

I have written a code which creates a binary expression tree from a given string expression: public ExprIF buildExpressionTree(String s) { for(int i = 0; i<s.length(); i++) { ...
-1
votes
2answers
50 views

Print in Java Char array as binary

I've a char array static char[] myArray ={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x48, 0x48, 0x48, 0xb0, 0x00, 0xc0, 0x20, 0x20, 0x20, 0xc0, 0x00, 0xc0, 0x20, 0x20, 0x20, 0xc0, ...
0
votes
0answers
57 views

How to print from binary file using information from a Schema file?

If I have a Schema file and need to print out information from a Binary File, based on the schema definition for the binary file. The schema file is written: char int double An example ...
0
votes
2answers
126 views

Balanced Binary Search Tree

I need to build a balanced binary search tree. So far my program inserts the numbers from 1 to 26, but my program does not build it into a balanced binary search tree. If anyone could look at my code ...
-2
votes
0answers
137 views

Balanced Binary Search Tree in JAVA [closed]

Hi I need some help with my homework. I am trying to build a balanced binary search tree from an unbalanced binary tree. I believe I am close to the answer, but just need some help bringing it all ...
0
votes
3answers
95 views

How to read a big binary file in Java

I want to read a binary file in Java, which contains m datasets. I know that each dataset consists of 3 elements: a long number, a double number and a long number in that sequence. The datasets are ...
0
votes
1answer
56 views

Java Binary search not working

I have an insertion search in the main and from there I call the BinarySearch method to search for a number within the array that has already been sorted. I try to compile it I get errors here is my ...
1
vote
2answers
38 views

Is there a Java/JVM server that supports streaming binary over websocket?

Does there exist an open source Java server/library/framework that supports bidirectional streaming of binary over websockets? I looked at a couple of them but couldn't find them mentioning binary ...
-4
votes
0answers
23 views

Java BinaryProducts database project [closed]

Hi everyone :) :) I have a question I hope you Guys can help with.... i am taking this computer programming class and my friend told me if I post a queston here I can get some help.... Well I am ...
-1
votes
1answer
101 views

Java code to read .txt file and convert into binary representation

Help guys I am a bit stuck on this :( I am doing Simplified DES(SDES) in Java. How can I convert the files into binary representations before encryption? Any help is much appreciated. I am thinking ...
0
votes
3answers
70 views

Why is myArrayList.size(); producing incorrect/gigantic numbers?

Basically, I'm trying to write a program that converts a number from base 2 to base 10. What I tried doing was translating the process listed on this website under the "Doubling method" into a for ...
1
vote
2answers
71 views

Math pow alternative in java

I have a need to sum up power of 2 from any digit x to 0. If x=6,desired sum is 2pow6+2pow5+.....1. While I can always write a algorithm to wind down to 0 using Math.pow - this function seems ...
-4
votes
0answers
40 views

Base converter, base 10 to base 2, base 8, base 16. help me to do this [duplicate]

I'm in this Object Oriented class, but I just don't know how to do this. I know basic fundamentals but nothing like this. I am asked to create a program that converts #'s base 10 to base 2, base 8,and ...
-4
votes
2answers
306 views

Base 10 to base 2,8,16 conversion in java [duplicate]

I'm in this Object Oriented class, but I just don't know how to do this. I know basic fundamentals but nothing like this. I am asked to create a program that converts #'s base 10 to base 2, base 8,and ...
-9
votes
1answer
59 views

Generate a Binary File [closed]

I need to generate Binary numbers (Single Bit: ONLY 0 or 1 as Binary and NOT integers) and write them to a file I repeat again, I need them BINARY. this means I don't want to convert an integer to ...
-5
votes
1answer
42 views

How do I convert this method to a Recursive Binary Version? [closed]

I have a method that goes through an Array of Contacts and finds the index of a Contact based on the lastName given. I then have a method that uses that return value to find a Contact on the list. How ...
3
votes
6answers
99 views

Bitwise Operations Java - Long to Binary

I found this code for an arithmetic encoder and I'm a bit confused as to where the values mentioned in the comments are coming from. Can anyone go through whats happening in these operations step by ...
0
votes
3answers
107 views

Converting from Hexadecimal to Binary and vice versa. The Hard Way

I'm writing a code that should convert between binary, decimal, and hexadecimal. I have the binary and the decimal figured out but when I got to Hexadecimal I just got confused. How would you do this ...
-3
votes
2answers
38 views

Changing digit regex [closed]

I have a binary number say 11100011, and I want to count the sequences of 1s and 0s and append them to a string. so the above should give 332. How would I split the above with a java regex? say, ...
-6
votes
2answers
58 views

Number systems bin to any, hex to any, oct to any [closed]

I'm gonna need some help from you pro coders out there i quite need a java program that will convert the ff with SOLUTION oct -> bin oct -> dec oct -> hex hex -> oct ...
3
votes
1answer
35 views

Error in performing bit-wise OR and 32 bit sign bit extension in Java

I'm having trouble understanding bit-wise OR in java. I'm reading a Java programming book named "Apress Beginning Java7" by Jeff Friesen. And in that book at page-31 the author gave two 8 bit binary ...
0
votes
1answer
15 views

Is there a simple way to directly define binary numbers? (such as an equivalent to the 0x-notation for hexadecimal numbers)

If I have the hexadecimal representation of a number, say f2, I can directly store the number as an int using. int num = 0xf2; Then, System.out.println(num); yields the output 242 What if I ...
2
votes
2answers
196 views

Java two's complement binary to integer [duplicate]

I know that converting a decimal to binary with Integer.toBinaryString(355) = 0000000101100011 and Integer.toBinaryString(-355) = 1111111010011101 (where I ...
1
vote
1answer
111 views

Base64 to Binary Conversion using Java

I already went over the responses I found for the question I have posted, but I wasn't able to figure out something. I would really appreciate it if somebody could please articulate on this a little ...
0
votes
1answer
37 views

Binary Search and using SortKey for two arrays - Very detailed [Java]

I am making a program that reads a text file that looks like this: 3679 87 196 60 17914 12 18618 64 2370 65 584 85 18524 34 12024 ...
0
votes
2answers
56 views

Reading in positive long integer values into an array

I'm looking to read in a file of type .dat. I do not know the size of the file, however I do know that the contents will be in the form of 111000111 0101 0100 1 0011 110 0010 101 0001 11 0000 ...
0
votes
0answers
53 views

How to call TreeNode search from Java main class for a Binary Tree?

I am adding two methods to my binary Tree. the first one is search(), the second one is getFreq(). In my main class the user will select an option: See below: import java.util.*; public class ...
-1
votes
2answers
111 views

JAVA - Write binary number to a file and read it

How can i write to a file a binary number without it to cut the zeros . I'm writing like this : byte[] b = new BigInteger("1011010101010110", 2).toByteArray(); FileOutputStream fos = new ...
0
votes
1answer
48 views

Binary String Representation to File and the to String again

I need to put binary in a file and then getting it back again, but i need to make it with the less amount possible of space use in the file ( example 16 bits = 2 bytes) byte[] b = new ...
0
votes
3answers
310 views

Binary search tree and in-order traversal

I am trying to quickly implement a Binary search tree in Java. What is the best class to use that has methods for in-order traversal? (I have heard of TreeMap class. But it looks like the class does ...
-1
votes
1answer
131 views

Finding if a binary search tree is perfect and complete? [closed]

How would I go about finding whether a binary search tree is a perfect tree and also whether it's a complete tree? I'm trying to do this recursively as that is what's recommended. I already have a ...
-6
votes
1answer
60 views

Counting binary numbers [closed]

I am a beginner in Java Programming and i am having some trouble handling java numbers. I want to create a program with a loop which will print binary forms of the integers 0 to 5. i mean the output ...
0
votes
0answers
69 views

Unable to correctly read doubles in little endian from a binary file in Java

Using RandomAccessFile (initialised as raf with the "r" marker) I am trying to get a set of 3 doubles from a binary file, which is in little-endian. The doubles are contained in a block of 24 bytes in ...
-2
votes
1answer
65 views

Implementation of a recursive binary search [closed]

I am writing a program that stores appointments in an ArrayList. The user is asked to type in a date, a start time, and an end time for an appointment. The program needs to check if there is already ...
-2
votes
3answers
95 views

Make any file unopenable in java [closed]

I am creating some movie files in java. The file is in .mp4 format. As the video is taken from a security surveillance camera, i want to make this file look corrupted when opened by anyone in any ...
0
votes
1answer
101 views

Java: sum values in binary tree of integers weighted by depth

Here is my reference tree: 3 / \ 5 2 / / \ 1 4 6 Here is the expected output of the recursive method: (1*3) + (2 * (5 + 2)) + (3 * (1 + 4 + 6)) = 50 ...and here is the code I ...
0
votes
2answers
254 views

Using Binary Search to add to an ArrayList in order

Hello everyone hoping you can help me here, My problem is that I need to be able to search through an ArrayList using binary search and find where the correct place to add an object so that the list ...
1
vote
1answer
77 views

Java search entire tree for the smallest value

This is not a binary search tree, and does not follow any strict rules. The only rules are that each node is a positive integer and that each node can have either no children, one left child, or two ...
0
votes
2answers
36 views

Java Enormous Integers [duplicate]

How can you represent integer arithmetic for numbers larger than what a 32 or 64 bit processor allows. I'm trying to write a small Java calculator, and the input would have to be a string of numbers ...

1 2 3 4 5 9
15 30 50 per page