Skip to content

Commit 4a0f972

Browse files
Amrita Cyber Java Library
1 parent e2fa5da commit 4a0f972

File tree

66 files changed

+4009
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+4009
-0
lines changed

lib/jpl_20cys383/jpl_20cys383.iml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
<orderEntry type="library" name="json" level="project" />
11+
<orderEntry type="library" name="googlecode.json.simple" level="project" />
12+
</component>
13+
</module>

lib/jpl_20cys383/person.ser

108 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.ramaguru.amrita.cys.jpl.Streams;
2+
3+
import java.io.BufferedInputStream;
4+
import java.io.BufferedOutputStream;
5+
import java.io.FileInputStream;
6+
import java.io.FileOutputStream;
7+
import java.io.IOException;
8+
9+
/**
10+
* An example demonstrating the usage of BufferedInputStream and BufferedOutputStream to improve I/O performance.
11+
* This example reads data from the input file using BufferedInputStream and writes it to the output file using BufferedOutputStream.
12+
*
13+
* @author Ramaguru Radhakrishnan
14+
* @version 0.5
15+
*/
16+
public class BufferedStreamExample {
17+
/**
18+
* Reads data from the input file using BufferedInputStream and writes it to the output file using BufferedOutputStream.
19+
*
20+
* @param args The command-line arguments.
21+
*/
22+
public static void main(String[] args) {
23+
try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream("C:\\Projects_Java\\lib\\jpl_20cys383\\src\\com\\ramaguru\\amrita\\files\\input.txt"));
24+
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("C:\\Projects_Java\\lib\\jpl_20cys383\\src\\com\\ramaguru\\amrita\\files\\output.txt"))) {
25+
int byteData;
26+
while ((byteData = bis.read()) != -1) {
27+
bos.write(byteData); // Write the byte data to the output file
28+
}
29+
} catch (IOException e) {
30+
e.printStackTrace(); // Print the exception stack trace if an error occurs
31+
}
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.ramaguru.amrita.cys.jpl.Streams;
2+
3+
import java.io.ByteArrayInputStream;
4+
import java.io.IOException;
5+
6+
/**
7+
* An example demonstrating the usage of ByteArrayInputStream to read data from a byte array.
8+
*
9+
* @author Ramaguru Radhakrishnan
10+
* @version 0.5
11+
*/
12+
public class ByteArrayStreamExample {
13+
/**
14+
* Reads the data from the byte array and prints it to the console.
15+
*
16+
* @param args The command-line arguments.
17+
*/
18+
public static void main(String[] args) {
19+
byte[] data = { 50, 49, 85, 67, 89, 83 };
20+
try (ByteArrayInputStream bais = new ByteArrayInputStream(data)) {
21+
int byteData;
22+
while ((byteData = bais.read()) != -1) {
23+
System.out.print((char) byteData); // Convert the byte data to char and print
24+
}
25+
} catch (IOException e) {
26+
e.printStackTrace(); // Print the exception stack trace if an error occurs
27+
}
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.ramaguru.amrita.cys.jpl.Streams;
2+
3+
import java.io.DataInputStream;
4+
import java.io.DataOutputStream;
5+
import java.io.FileInputStream;
6+
import java.io.FileOutputStream;
7+
import java.io.IOException;
8+
import java.util.Arrays;
9+
10+
/**
11+
* An example demonstrating the usage of DataInputStream and DataOutputStream to read and write primitive data types.
12+
*
13+
* @author Ramaguru Radhakrishnan
14+
* @version 0.5
15+
*/
16+
public class DataStreamExample {
17+
/**
18+
* Writes an integer and a double value to the file using DataOutputStream,
19+
* and then reads the values back using DataInputStream and prints them.
20+
*
21+
* @param args The command-line arguments.
22+
*/
23+
public static void main(String[] args) {
24+
try (DataOutputStream dos = new DataOutputStream(new FileOutputStream("C:\\Projects_Java\\lib\\jpl_20cys383\\src\\com\\ramaguru\\amrita\\files\\data.bin"));
25+
DataInputStream dis = new DataInputStream(new FileInputStream("C:\\Projects_Java\\lib\\jpl_20cys383\\src\\com\\ramaguru\\amrita\\files\\data.bin"))) {
26+
dos.writeInt(44); // Write the integer value
27+
dos.writeDouble(3.14); // Write the double value
28+
dos.writeChars("Ramaguru R"); // Write the String value
29+
30+
int intValue = dis.readInt(); // Read the integer value
31+
double doubleValue = dis.readDouble(); // Read the double value
32+
String stringvalue = Arrays.toString(dis.readAllBytes()); // Read the String value as Array
33+
34+
System.out.println("Read values: " + intValue + ", " + doubleValue + "," + stringvalue);
35+
} catch (IOException e) {
36+
e.printStackTrace(); // Print the exception stack trace if an error occurs
37+
}
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.ramaguru.amrita.cys.jpl.Streams;
2+
3+
import java.io.FileInputStream;
4+
import java.io.IOException;
5+
6+
/**
7+
* An example demonstrating the usage of FileInputStream to read data from a file as a sequence of bytes.
8+
*
9+
* @author Ramaguru Radhakrishnan
10+
* @version 0.5
11+
*/
12+
public class FileStreamExample {
13+
/**
14+
* Reads the data from the file and prints it to the console.
15+
*
16+
* @param args The command-line arguments.
17+
*/
18+
public static void main(String[] args) {
19+
try (FileInputStream fis = new FileInputStream("example.txt")) {
20+
int data;
21+
while ((data = fis.read()) != -1) {
22+
System.out.print((char) data); // Convert the byte data to char and print
23+
}
24+
} catch (IOException e) {
25+
e.printStackTrace(); // Print the exception stack trace if an error occurs
26+
}
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.ramaguru.amrita.cys.jpl.Streams;
2+
3+
import java.io.FileInputStream;
4+
import java.io.IOException;
5+
import java.io.InputStreamReader;
6+
import java.nio.charset.StandardCharsets;
7+
8+
/**
9+
* An example demonstrating the usage of InputStreamReader to read data from an underlying input stream and convert it into characters.
10+
*
11+
* @author Ramaguru Radhakrishnan
12+
* @version 0.5
13+
*/
14+
public class InputStreamReaderExample {
15+
/**
16+
* Reads the data from the input stream and prints it to the console.
17+
*
18+
* @param args The command-line arguments.
19+
*/
20+
public static void main(String[] args) {
21+
try (FileInputStream fis = new FileInputStream("C:\\Projects_Java\\lib\\jpl_20cys383\\src\\com\\ramaguru\\amrita\\files\\example.txt");
22+
InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8)) {
23+
int charData;
24+
while ((charData = isr.read()) != -1) {
25+
System.out.print((char) charData); // Print the character data
26+
}
27+
} catch (IOException e) {
28+
e.printStackTrace(); // Print the exception stack trace if an error occurs
29+
}
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.ramaguru.amrita.cys.jpl.Streams;
2+
3+
import java.io.FileInputStream;
4+
import java.io.FileOutputStream;
5+
import java.io.IOException;
6+
import java.io.ObjectInputStream;
7+
import java.io.ObjectOutputStream;
8+
import java.io.Serializable;
9+
10+
/**
11+
* An example demonstrating the usage of ObjectInputStream and ObjectOutputStream to read and write objects.
12+
*
13+
* @author Ramaguru Radhakrishnan
14+
* @version 0.5
15+
*/
16+
class Person implements Serializable {
17+
private String name;
18+
private int age;
19+
20+
/**
21+
* Constructs a Person object with the specified name and age.
22+
*
23+
* @param name The name of the person.
24+
* @param age The age of the person.
25+
*/
26+
public Person(String name, int age) {
27+
this.name = name;
28+
this.age = age;
29+
}
30+
31+
@Override
32+
public String toString() {
33+
return "Person [name=" + name + ", age=" + age + "]";
34+
}
35+
}
36+
37+
/**
38+
* An example demonstrating the usage of ObjectInputStream and ObjectOutputStream to read and write objects.
39+
*
40+
*/
41+
public class ObjectStreamExample {
42+
/**
43+
* Serializes a Person object into a file and then deserializes it back.
44+
*
45+
* @param args The command-line arguments.
46+
*/
47+
public static void main(String[] args) {
48+
Person person = new Person("John", 25);
49+
50+
// Serialization
51+
try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("C:\\Projects_Java\\lib\\jpl_20cys383\\src\\com\\ramaguru\\amrita\\files\\person.ser"))) {
52+
oos.writeObject(person);
53+
System.out.println("Person object serialized and saved to 'person.ser'");
54+
} catch (IOException e) {
55+
e.printStackTrace();
56+
}
57+
58+
// Deserialization
59+
try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream("C:\\Projects_Java\\lib\\jpl_20cys383\\src\\com\\ramaguru\\amrita\\files\\person.ser"))) {
60+
Person deserializedPerson = (Person) ois.readObject();
61+
System.out.println("Deserialized Person: " + deserializedPerson);
62+
} catch (IOException | ClassNotFoundException e) {
63+
e.printStackTrace();
64+
}
65+
}
66+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.ramaguru.amrita.cys.jpl.apps;
2+
3+
import java.awt.image.BufferedImage;
4+
import java.io.File;
5+
import java.io.IOException;
6+
import javax.imageio.ImageIO;
7+
8+
/**
9+
* The ImageSplicingDetection class is an application that detects splicing in an image.
10+
* It reads an image file, performs splicing detection, and outputs the result.
11+
*
12+
* Dependencies:
13+
* - Requires Java AWT and ImageIO libraries.
14+
*
15+
* Usage:
16+
* - Specify the path to the image file in the 'imagePath' variable.
17+
* - The 'detectSplicing' method contains the splicing detection algorithm, which can be implemented based on specific requirements.
18+
* - The main method reads the image file, calls the 'detectSplicing' method, and displays the result.
19+
*
20+
* Note: This example includes a placeholder implementation for splicing detection that assumes all images are spliced.
21+
*
22+
* @author Ramaguru Radhakrishnan
23+
* @version 0.5
24+
*/
25+
public class ImageSplicingDetection {
26+
27+
/**
28+
* The main method is the entry point of the application.
29+
* It reads an image file, performs splicing detection, and outputs the result.
30+
*
31+
* @param args command line arguments
32+
*/
33+
public static void main(String[] args) {
34+
String imagePath = "C:\\Projects_Java\\jpl_20cys383\\src\\com\\ramaguru\\amrita\\images\\21UCYS.jpeg";
35+
36+
try {
37+
BufferedImage image = ImageIO.read(new File(imagePath));
38+
boolean isSpliced = detectSplicing(image);
39+
40+
if (isSpliced) {
41+
System.out.println("Image appears to be spliced.");
42+
} else {
43+
System.out.println("Image does not appear to be spliced.");
44+
}
45+
} catch (IOException e) {
46+
System.out.println("Error reading the image: " + e.getMessage());
47+
}
48+
}
49+
50+
/**
51+
* Detects splicing in the given image.
52+
* This method contains the splicing detection algorithm.
53+
* Modify the implementation based on specific splicing detection requirements.
54+
*
55+
* @param image the image to be checked for splicing
56+
* @return true if splicing is detected, false otherwise
57+
*/
58+
public static boolean detectSplicing(BufferedImage image) {
59+
// Implement your splicing detection algorithm here
60+
// This is a placeholder implementation that assumes all images are spliced
61+
return true;
62+
}
63+
}

0 commit comments

Comments
 (0)