Skip to content

Instantly share code, notes, and snippets.

@SatyaSnehith
SatyaSnehith / Ip.java
Created November 8, 2018 17:01
Get IP Address of a Device
import java.net.*;
import java.util.*;
public class Ip {
public static void main(String[] args) {
getIPAddress();
}
String getSubnetAddress(String ip) {
@SatyaSnehith
SatyaSnehith / Server.java
Last active November 9, 2018 14:39
This Server accepts requests and sends information
import java.io.*;
import java.net.*;
import java.util.Scanner;
public class Server {
private ServerSocket serverSocket = null;
private Socket socket = null;
private ServerThread serverThread;
Server(int port) {
@SatyaSnehith
SatyaSnehith / Stopwatch.java
Last active January 21, 2022 12:36
Stopwatch application in JavaFX
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
@SatyaSnehith
SatyaSnehith / Converter.java
Last active May 4, 2024 08:06
Convert Bytes to KB, MB, GB, TB - java
public class Converter{
static long kilo = 1024;
static long mega = kilo * kilo;
static long giga = mega * kilo;
static long tera = giga * kilo;
public static void main(String[] args) {
for (String arg: args) {
try {
System.out.println(getSize(Long.parseLong(arg)));
@SatyaSnehith
SatyaSnehith / FileChooserDialog.java
Created December 4, 2017 18:37
File Chooser Dialog for Android
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.ActionMode;
import android.view.LayoutInflater;
public class Speed {
private final File FOLDER = new File("Files");
String name = "movie.mp4";
int port = 46789;
public static void main(String[] args) {
try {
ServerSocket serverSocket = new ServerSocket(port);
serverSocket.setReuseAddress(true);
Socket socket = serverSocket.accept();
byte[] buffer = new byte[1024*1024];