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
struct env_type | |
{ | |
int *(*GetIntArrayElements)(struct jintArray); | |
int *(*ReleaseIntArrayElements)(struct jintArray, int *native_array); | |
}; |
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
JNIEXPORT jint JNICALL Java_ShortWeight_matrixWeight | |
(JNIEnv * env, jobject jobj, jintArray matrix_values, jint rows, jint columns) | |
{ | |
jint *matrix_ptr; | |
matrix_ptr = (*env)->GetIntArrayElements(env, matrix_values, NULL); | |
(*env)->ReleaseIntArrayElements(env, matrix_values, matrix_ptr, 0); | |
} |
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
struct env_type create_env_structure() | |
{ | |
struct env_type env_struct, *env_ptr; | |
env_struct.GetIntArrayElements = &GetIntArrayElementsFunc; | |
env_struct.ReleaseIntArrayElements = &ReleaseIntArrayElementsFunc; | |
return env_struct; | |
} |
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
int *GetIntArrayElementsFunc(struct jintArray jvm_array) | |
{ | |
int size = jvm_array.size; | |
int *native_array = malloc(size * sizeof(int)); | |
for (int i = 0; i < size; i ++){ | |
native_array[i] = jvm_array.elements[i]; | |
} | |
return native_array; | |
} |
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
#include <stdio.h> | |
#include <stdlib.h> | |
struct jintArray | |
{ | |
int size; | |
int *elements; | |
}; |
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 FileReaderTest { | |
public static void main(String[] args) { | |
String filename = "./public/non_existent.file"; | |
try { | |
List<String> allLines = Files.readAllLines(Paths.get(filename), Charset.defaultCharset()); | |
for ( String i : allLines ) { | |
System.out.println(i); | |
} |
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.*; | |
import java.nio.charset.Charset; | |
import java.nio.file.Files; | |
import java.util.List; | |
import java.nio.file.Paths; | |
public class FileReaderTest { | |
public static void main(String[] args) { | |
String filename = "./public/index.html"; |
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 FileReaderTest { | |
public static void main(String[] args) { | |
String filename = "./public/index.html"; | |
try { | |
List<String> allLines = Files.readAllLines(Paths.get(filename), Charset.defaultCharset()); | |
for ( String i : allLines ) { | |
System.out.println(i); | |
} |
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.File; | |
public class FileReaderTest { | |
public static void main(String[] args) { | |
File newFile = new File("./public/sample_file.text"); | |
FileInputStream fileStream = new FileInputStream(newFile); | |
} | |
} |
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.File; | |
import java.io.FileNotFoundException; | |
public class FileReaderTest { | |
public static void main(String[] args) { | |
File newFile = new File("./public/sample_file.text"); | |
try { |