This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
NewerOlder