141 Reusable Code Snippet Topics
Remove Filter | |
I have seen many people struggling with Reading files and writing files in java, also a great problem is how to edit a file too. So in this code snippet I have put all these problems into one small program in hopes to help others. So this code snippet will … | |
The program below is written in **Java** and is used to develop a Web Server that supports these status codes: **200** OK, **302** Moved Temporarily, and **404** NOT FOUND. The code can emulate an **HTTP** server in your local machine. Let me know if you find the code below helpful … | |
Basically this scheme uses variable offsets, but it generates the bytes on the fly. They aren't truly random, but there aren't any obvious patterns and the output passes all the NIST tests. Since a simple password can be used to do the de/encryption it is much easier to hand off … | |
Write a program using for loops to produce an R by C rectangle, where R and C are provided by the user. The following are the triangles for different values of R and C. R is the number of rows and C is the number of columns | |
The Action Driver Class when it runs it just brings up a small box with java logo and close and minimize options thats all...... I have reviewd the code over and over and my instuctor said to just review my work... I am so lost.... | |
this is the task given to me guix i hope you can help me Create a program that will read the data from a file and save the output in another file 1.Create an input file named **CS122Grades**. 2.The contents of the input file should be the **names**,**midterm grades** and … | |
Easy tutorial: https://slicker.me/javascript/tower.htm | |
There are times when you need to make sure your counter starts at an odd or even number. Even is pretty simple - `counter = counter + modulus(counter)`. If counter is even it stays, if it's odd it gets incremented by 1. Odd is a bit more complicated - `counter … | |
[Pulsating Spirograph (Processing)](https://www.ktbyte.com/projects/project/93961/pulsating-spirograph?ref=20181212daniweb2) | |
[[Depths (Made with Processing)](https://www.ktbyte.com/projects/project/94051/depths?ref=20181210daniweb)](null) | |
Here's an interesting little scenario. You get challenged to a game of coin toss. Both players pick a sequence of coin toss results (heads or tails). The coin is repeatedly tossed until the sequence for one of the players occurs. The loser pays the winner a dollar. You'd assume that … | |
This is a little discussion/example of design for modularity and re-use, inspired by javaAddict and Orlando Augusto posts in their thread “Dynamic Multidimensional Array Printing” https://www.daniweb.com/programming/software-development/code/305580/dynamic-multidimensional-array-printing That thread has 3 solutions to printing the contents of a multi-dimensional array of arbitrary dimensions - although in fact all the solutions will … | |
Hi All. This is my first code snippet. I don't know how practical it is, but I came up with the idea, so I wanted to do it. Assuming you have an array. You use a for loop to display its data. For 2D arrays you use 2 for loops. … | |
This class is intended as a small and simple alternative to java.util.Scanner for people in the early stages of learning Java. Unlike Scanner it has built-in error handling and retry, it throws no checked exceptions, is as tolerant as possible of variations in the format of user input, and avoids … | |
i have to write a code that has a random number generated between 1-100 and the user has the choice to keep the number, discard the number and quit the program. and when the user quits the program displays the numbers kept and discarded, but i dont know how to … | |
Hi everyone this is my first code snippet so be gentle.. I have written a basic client/server chat program that uses multithreading for listening and sending. I welcome any improvements or discussion... Thanks James | |
When users interact with your web page and processes, it is important to provide them with continuous feedback. Without the feedback, a user is left wondering if you page is actually processing work, frozen, or just not working. This is especially true when incorporating Ajax requests that take more than … | |
The code simply captures your working window as jpeg image and stores it in the same directory as where your java class after compiling by javac is being stored | |
here where am doing mistake and program is showing error non static method cannot be refferenced to static context | |
Similarly, you can add more fields to an enum and simply provide accessor methods to retrieve them. For example you could change it to have an extra field indicating an output directory to write specific types of data to, and a getter method to return that directory. | |
**This is intented for learning purposes, feel free to study the code** Create a drawing that looks like this (pyramid) The number should be incremented with the modulus. | |
Hey everybody, Lately I have written the game Hangman in many different languages (C, JavaScript, Java and PHP so far). Here is the code snippet for Java! It uses a words file, on the bottom of this post you will see a small example of a few words. The source … | |
I made this minesweeper game earlier this summer. It shows many things, including: array use, 1D array to 2D array, gridlayout, changing the way a JButton works depending on mouse button used, floodfill, loops, GUI. slightly long, 382 lines, can probably be condensed. There is one known bug that i … | |
The server only does the basics. TODOs: The header method needs expanding. The file send method can't handle too large files. Maybe write custom buffer class since some buffering is done. Keep cache of recent files. | |
I have recently been interested in Java Swing and Game development, so naturally I began creating many different 2D games. During them I found myself having to rewrite much code, but eventually I decided to write some classes that would help me whenever I wanted to make a game. Here … | |
Hello This is a demo showing Java interacting with Daniweb's new API ( http://www.daniweb.com/api/documentation ) You introduce a member's name and it should show you the total number of posts he has made. Demo is a proof of concept: No bug checking, error checking, etc is in this code. In … | |
I have seen many questions on autocompeletion for *java text components* like `JTextField` `JTextArea` `JTextEditorPane` etc. There are not many options either: 1) 3rd party library (like SwingX) 2) DIY (i.e using `DocumentListener`, `JWindow` with `JLabel` etc and a few requestFocusInWindow calls) I chose number 2 and put the code … | |
A temperature converter GUI. Converts from Celsius to Fahrenheit and vise versa. Tests JLabels, JButtons and JTextFields. *Two separate programs, Converter and Thermometer (Thermometer Class)* | |
The above code computes the value of a mathematical expression supplied at command line by using the concept of converting infix to postfix,then evaluating the postfix expression. Any comments are appreciated. | |
Just a simple Jython code to test drawing on the canvas. |
The End.