Java.Streams.What are “channels”?

⚡ Let’s dive into the concept of channels in Java NIO — they’re at the heart of NIO’s power and flexibility.

Continue reading →
Posted in Без рубрики | Comments Off on Java.Streams.What are “channels”?

Java.What features of NIO do you know?

✅ Core Features of Java NIO (New I/O)


🔹 1. Channels

  • Abstraction for reading/writing data to files, sockets, etc.
  • Can be bi-directional (read + write)
  • Work with Buffers, not streams
FileChannel channel = new FileInputStream("file.txt").getChannel();
Continue reading →
Posted in Без рубрики | Comments Off on Java.What features of NIO do you know?

Java.Streams.What is Channel ?

🧠 Summary

Use IO when…Use NIO when…
Simpler, small file I/OHigh-performance or scalable I/O
Blocking behavior is okayYou need non-blocking I/O (e.g., sockets)
You want simplicityYou need power, flexibility, and performance

✅ What is a Channel?

In Java NIO, a Channel is like a modern alternative to InputStream/OutputStream, but more powerful.

It represents a connection to a data source (like a file, socket, etc.), through which you can read, write, or both.

Continue reading →
Posted in Без рубрики | Comments Off on Java.Streams.What is Channel ?

Java.Streams.What is the difference between IO and NIO?

⚙️ Let’s break down the difference between IO (java.io) and NIO (java.nio) — two major APIs for handling input/output in Java.

Continue reading →
Posted in Без рубрики | Comments Off on Java.Streams.What is the difference between IO and NIO?

Java8.How to create Base64 encoder and decoder?

🔐 In Java 8, creating a Base64 encoder and decoder is super simple using the built-in java.util.Base64 class.

Let’s walk through how to create and use both.

Continue reading →
Posted in Без рубрики | Comments Off on Java8.How to create Base64 encoder and decoder?

Java.Java8.What class was introduced in Java 8 for encoding/decoding data?

🧩 In Java 8, the class introduced for encoding and decoding data, especially in Base64, is:


✅ java.util.Base64

This class provides built-in support for Base64 encoding and decoding — no more need for third-party libraries or Apache Commons!

Continue reading →
Posted in Без рубрики | Comments Off on Java.Java8.What class was introduced in Java 8 for encoding/decoding data?

Java.What is GraalVM ?

⚙️ GraalVM is one of the most exciting technologies in the Java ecosystem today. Let’s break it down simply and clearly.

Continue reading →
Posted in Без рубрики | Comments Off on Java.What is GraalVM ?

Java.Java8.What is jjs?

✅ What is jjs?

jjs was a command-line tool introduced in Java 8 that allowed you to run JavaScript code directly using the Nashorn JavaScript engine.

Think of it as a mini JavaScript REPL or script runner inside your JDK.


🔹 Example Usage

jjs

You’d get an interactive shell like this:

jjs> print("Hello from Nashorn!");
Hello from Nashorn!

Or run a script file:

jjs myscript.js

✅ What Could You Do with jjs?

  • Run JavaScript code from the terminal
  • Import and use Java classes from JavaScript
  • Do quick scripting or automation tasks using the JVM

🔧 Example: Calling Java from JavaScript

// hello.js
var ArrayList = Java.type("java.util.ArrayList");
var list = new ArrayList();
list.add("Java + JS");
print(list.get(0));

Then run:

jjs hello.js

❌ Deprecation & Removal

StatusJava Version
DeprecatedJava 11
RemovedJava 15

Why? Because Nashorn couldn’t keep up with newer JavaScript standards (ES6+), and newer tools like GraalVM replaced it.


🧠 Summary

FeatureDescription
jjsJavaScript shell for Nashorn
UseRun JavaScript + call Java classes
Removed inJava 15
Replaced byGraalVM, Node.js for modern JS

Posted in Без рубрики | Comments Off on Java.Java8.What is jjs?

Java.Java8.What is Nashorn?

🧠 What is Nashorn?

Nashorn is a JavaScript engine built into the Java 8 platform.

It allows you to run JavaScript code inside a Java application.

Continue reading →
Posted in Без рубрики | Comments Off on Java.Java8.What is Nashorn?

Java.Java8.How to define repeatable annotation?

✅ What Is a Repeatable Annotation?

It means you can write something like this:

@Hint("first hint")
@Hint("second hint")
public class MyClass { }

To make this possible, you need to define:

  1. The repeatable annotation
  2. A container annotation that holds multiple instances
Continue reading →
Posted in Без рубрики | Comments Off on Java.Java8.How to define repeatable annotation?