Skip to content

Instantly share code, notes, and snippets.

View rmg007's full-sized avatar
💭
✧*。٩(ˊᗜˋ*)و✧*。

Ryan Gonzalez rmg007

💭
✧*。٩(ˊᗜˋ*)و✧*。
View GitHub Profile
@rmg007
rmg007 / BufferedReaderBufferedWriterExample.java
Created October 29, 2022 16:37
BufferedReade rBufferedWriter Example
import java.io.*;
public class BufferedReaderBufferedWriterExample {
static String filePath = "/Users/ryan/Desktop/file.txt";
public static void main(String[] args) throws IOException {
//String word = "hello java";
//char[] chars = word.toCharArray();
//try(FileWriter fw = new FileWriter(filePath);
//BufferedWriter bw = new BufferedWriter(fw)){
// bw.write(word);
@rmg007
rmg007 / BufferedInputStreamBufferedOutputStreamExample.java
Created October 29, 2022 16:36
BufferedInputStream BufferedOutputStream Example
import java.io.*;
public class BufferedInputStreamBufferedOutputStreamExample {
// BufferedInputStream and BufferedOutputStream are efficient
// when reading and writing large files in chunks
static String filePath = "/Users/ryan/Desktop/file.txt";
public static void main(String[] args) throws IOException {
String word = "hello java";
@rmg007
rmg007 / CharArrayReaderWriter.java
Created October 29, 2022 16:34
CharArrayReader Writer Example
import java.io.CharArrayReader;
import java.io.CharArrayWriter;
import java.io.FileWriter;
import java.io.IOException;
public class CharArrayReaderWriter {
static String filePath = "/Users/ryan/Desktop/file.txt";
public static void main(String[] args) throws IOException {
String word = "java";
@rmg007
rmg007 / ByteArrayInputStreamByteArrayOutputStreamExample.java
Created October 29, 2022 16:33
ByteArrayInputStream ByteArrayOutputStream Example
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class ByteArrayInputStreamByteArrayOutputStreamExample {
static String filePath = "/Users/ryan/Desktop/file.txt";
public static void main(String[] args) throws IOException {
String word = "java";
byte[] bytes = word.getBytes();
@rmg007
rmg007 / FileInputStreamOutputStreamExample.java
Created October 29, 2022 16:32
FileInputStream FileOutputStream Example
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class FileInputStreamOutputStreamExample {
/*
J a v a - i s - a w e s o m e
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 2 3 4 5 6 7 8 9 10
*/
@rmg007
rmg007 / FileReaderWriterExample.java
Created October 29, 2022 16:30
File Reader Writer Example
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class FileReaderWriterExample {
//FileReader is meant for writing streams of characters
// File Writer is meant for writing streams of characters
static String filePath = "/Users/ryan/Desktop/file.txt";
@rmg007
rmg007 / GuessTheNumber.java
Created October 21, 2022 14:55
Guess the Number
import java.util.Random;
import java.util.Scanner;
/*
lecture 130 in learn and dive deep in Java course
https://www.udemy.com/course/best-java-course/?referralCode=3F66CEAE090AA62ADCB2
*/
public class GuessTheNumber{
public static void main(String[] args) {
@rmg007
rmg007 / RandomNumbers.java
Created October 21, 2022 11:59
Generate Random Numbers in Java
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
public class RandomNumbers {
public static void main(String[] args) {
for (int i = 0; i < 100; i++) {
System.out.println(getRandomNumber_4(4, 9));
}
}
@rmg007
rmg007 / MathMethodsExample.java
Created October 21, 2022 11:58
Math Method Examples
public class MathMethodsExample {
public static void main(String[] args) {
System.out.println("Max of 6 and 9: " + Math.max(6, 9));
System.out.println("Min of 6 and 9: " + Math.min(6, 9));
System.out.println("The PI value: " + Math.PI);
System.out.println("Square root of 36: " + Math.sqrt(36));
System.out.println("Cube root of 125: " + Math.cbrt(125));
@rmg007
rmg007 / TimeZones.java
Created October 21, 2022 11:57
TimeZoneId Examples
import java.time.*;
import java.util.Map;
import java.util.Set;
public class TimeZones {
/*
ZoneId Formats:
20:30Z
GMT+02:00
America/Los_Angeles (Area/City)