Exception in thread "main" java.lang.ArithmeticException: Access denied at Main.main(Main.java:3)
Output of 13 Syntax:Exception handling 03
Output of 13 Syntax:Exception handling 03
👍1
//14 Syntax:File Create / write
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public class CreateFile {
public static void main(String[] args) {
try {
File Obj = new File("Give Location where to create File");
if (Obj.createNewFile()) {
System.out.println("File created: " + Obj.getName());
FileWriter MWriter = new FileWriter("give Location of file which to write");
MWriter.write("What am I writting");
MWriter.close();
System.out.println("Successfully wrote to the file.");
} else {
System.out.println("File already exists.");
}
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
}
//Note This code can only run in Your PC
❤1👍1
Output:
File created: test.txt
Successfully wrote to the file
Output of 14 Syntax:File Create / write
File created: test.txt
Successfully wrote to the file
Output of 14 Syntax:File Create / write
//14 Syntax:File Read / Info
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class ReadFile {
public static void main(String[] args) {
File Obj = new File("Location of text File");
if (Obj.exists()) {
System.out.println("File name: " + Obj.getName());
System.out.println("Absolute path: " + Obj.getAbsolutePath());
System.out.println("Writeable: " + Obj.canWrite());
System.out.println("Readable " + Obj.canRead());
System.out.println("File size in bytes " + Obj.length());
}
else {
System.out.println("The file does not exist.");
}
try {
File ObjR = new File("Location of text file");
Scanner MReader = new Scanner(ObjR);
while (MReader.hasNextLine()) {
String data = MReader.nextLine();
System.out.println(data);
}
MReader.close();
}catch (FileNotFoundException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
}
//Note This code can only run in Your PC
👍2
Output:
File name: test.txt
Absolute path: /home/runner/compilers/./test/test.txt
Writeable: true
Readable true
File size in bytes 18
What am I writting
Output of 14 Syntax:File Read / Info
File name: test.txt
Absolute path: /home/runner/compilers/./test/test.txt
Writeable: true
Readable true
File size in bytes 18
What am I writting
Output of 14 Syntax:File Read / Info
//14 Syntax:File Delete and folder
import java.io.File;
public class DeleteFile {
public static void main(String[] args) {
try{
File DObj = new File("Location Of File");
if (DObj.delete()) {
System.out.println("Deleted the file: " + DObj.getName());
} else {
System.out.println("Failed to delete the file.");
}
}catch(Exception e){
System.out.println("Failed to delete the folder.");
}
finally{
File DFObj = new File("Location of Folder");
if (DFObj.delete()) {
System.out.println("Deleted the folder: " + DFObj.getName());
} else {
System.out.println("Failed to delete the folder.");
}
}
}
}
//Note This code can only run in Your PC
👍4
Output:
Deleted the file: test.txt
Failed to delete the folder.
Output of 14 Syntax:File Delete and folder
Deleted the file: test.txt
Failed to delete the folder.
Output of 14 Syntax:File Delete and folder
Remaining Topics like Inheritance, Polymorphism, Hash Map, Wrapper Classes, Regex, Threads, Lamda will be added soon
Create compiler bot in mobile
Run any language codes
In hindi:
Ab laptop ko kar do Tata bye bye gya 😂
https://youtu.be/352o8B9IikI?si=OSrhBU0mcFEkqILA
Run any language codes
In hindi:
Ab laptop ko kar do Tata bye bye gya 😂
https://youtu.be/352o8B9IikI?si=OSrhBU0mcFEkqILA
YouTube
How to create compiler bot and run c/c++ java python node js ts from mobile as server in termux
How to create compiler bot and run c/c++ java python node js ts from mobile as server in termux
Create own compiler bot in 2 minutes
Overview:
In this video, I exaplained You about how to use clone Compiler bot to create your own compiler bot.
keys:…
Create own compiler bot in 2 minutes
Overview:
In this video, I exaplained You about how to use clone Compiler bot to create your own compiler bot.
keys:…
👍3
Java all Codes listed see pin message 👆
Or you can search any keyword
Example: "function" to see function related codes
Or you can search any keyword
Example: "function" to see function related codes
#Taskforyou
Write a Java program that remove the extra spaces from the following string:
' I am learning Java object oriented programming '
Write a Java program that remove the extra spaces from the following string:
' I am learning Java object oriented programming '
👍1
Write code on task's comment, which code will be best that code should be posted here with those name
After 8pm today
After 8pm today
👍1
#TaskAnswer
public class TaskAnswer {
public static void main(String[] args) {
String str = "I am learning Java object oriented programming";
str = str.replaceAll("\\s", "");
System.out.println(str);
}
}
Output:
Iamlearningobjectorientedprogramming
public class TaskAnswer {
public static void main(String[] args) {
String str = "I am learning Java object oriented programming";
str = str.replaceAll("\\s", "");
System.out.println(str);
}
}
Output:
Iamlearningobjectorientedprogramming
👍2
Explanation:
str = str.replaceAll("\\s", "") : This line replaces all whitespace characters in the string
str = str.replaceAll("\\s", "") : This line replaces all whitespace characters in the string
str with an empty string, effectively removing them. The \\s is a regular expression pattern that matches any whitespace character, such as spaces, tabs, or newlines. The double backslash \\ is necessary because \ is an escape character in Java strings, so to represent a single backslash in a regular expression, you need to escape it with another backslash.
Java Codes Basic to Advance
Write your Code in Comment below 👇👇
Solution:
import java.util.Scanner;
public class Pattern {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter the value of n: ");
int n = scan.nextInt();
for (int i = 1 ; i <= n; i++) {
for (int j = 1; j <= n - i; j++) {
System.out.print("1 ");
}
for(int k = 1; k <= i; k++){
System.out.print(i + " ");
}
System.out.println();
}
}
}👍7
If you want learn js for website development 👇join it
@react_next_js
For any problems in js site development feel free to ask questions 😊👇
@reactjs_nextjs_group
@react_next_js
For any problems in js site development feel free to ask questions 😊👇
@reactjs_nextjs_group
👍2
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Free Study Resources everything join more ✅ https://t.me/addlist/c3QWwWR-Iw4xMDNl
Subscribe Our New channel for coding, designing, hacking and computer related everything 😁
👉✅ https://youtube.com/@CODEBOMBB
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Free Study Resources everything join more ✅ https://t.me/addlist/c3QWwWR-Iw4xMDNl
Subscribe Our New channel for coding, designing, hacking and computer related everything 😁
👉✅ https://youtube.com/@CODEBOMBB
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
👍2
This media is not supported in your browser
VIEW IN TELEGRAM
👩💻 Welcome to @CodesSnippet! 🔫
Join us for daily snippets of coding👩💻 knowledge! 💻
Here, you'll find 👀 bite-sized pieces of code, programming tips, and tricks to level up your coding skills! 💻
Stay updated on the latest trends in the tech world and engage with fellow coders 💗 in our vibrant community! 🌐💬
Let's crack the coding 👩💻 together and bring your projects to life!
⭐️👨💻
Lang : Python , Java, Javascript, c++ and many more.
#CodeSnippet
#ProgrammingFun
Jᴏɪɴ ᴜs :- @CodesSnippet
Join us for daily snippets of coding👩💻 knowledge! 💻
Here, you'll find 👀 bite-sized pieces of code, programming tips, and tricks to level up your coding skills! 💻
Stay updated on the latest trends in the tech world and engage with fellow coders 💗 in our vibrant community! 🌐💬
Let's crack the coding 👩💻 together and bring your projects to life!
⭐️👨💻
Lang : Python , Java, Javascript, c++ and many more.
#CodeSnippet
#ProgrammingFun
Jᴏɪɴ ᴜs :- @CodesSnippet
👍2❤1