Skip to content

Commit

Permalink
feat: basic file implementation (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
NexelOfficial authored Jun 25, 2024
1 parent 5029551 commit 0b9378d
Showing 1 changed file with 121 additions and 0 deletions.
121 changes: 121 additions & 0 deletions src/java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,52 @@ declare global {
}
}
namespace util {
class Scanner {
constructor(source: io.File);
constructor(source: io.File, charsetName: string);
constructor(source: string);

close(): void;
findInLine(pattern: string): string | null;
findWithinHorizon(pattern: string, horizon: number): string | null;
hasNext(): boolean;
hasNext(pattern: string): boolean;
hasNextBigDecimal(): boolean;
hasNextBigInteger(): boolean;
hasNextBigInteger(radix: number): boolean;
hasNextBoolean(): boolean;
hasNextByte(): boolean;
hasNextByte(radix: number): boolean;
hasNextDouble(): boolean;
hasNextFloat(): boolean;
hasNextInt(): boolean;
hasNextInt(radix: number): boolean;
hasNextLine(): boolean;
hasNextLong(): boolean;
hasNextLong(radix: number): boolean;
hasNextShort(): boolean;
hasNextShort(radix: number): boolean;
next(): string;
next(pattern: string): string;
nextBoolean(): boolean;
nextDouble(): number;
nextFloat(): number;
nextInt(): number;
nextInt(radix: number): number;
nextLine(): string;
nextLong(): number;
nextLong(radix: number): number;
nextShort(): number;
nextShort(radix: number): number;
radix(): number;
remove(): void;
reset(): Scanner;
skip(pattern: string): Scanner;
toString(): string;
useDelimiter(pattern: string): Scanner;
useRadix(radix: number): Scanner;
}

interface Collection<T = any> extends java.lang.Iterable<T> {
add(value: T): boolean;
addAll(collection: java.util.Collection<T>): boolean;
Expand Down Expand Up @@ -126,5 +172,80 @@ declare global {
interface Pattern {}
}
}
namespace io {
class File {
constructor(parent: File, child: string);
constructor(pathName: string);
constructor(parent: string, child: string);

canExecute(): boolean;
canRead(): boolean;
canWrite(): boolean;
compareTo(pathname: File): number;
createNewFile(): boolean;
static createTempFile(prefix: string, suffix: string): File;
static createTempFile(prefix: string, suffix: string, directory: File): File;
delete(): boolean;
deleteOnExit(): void;
exists(): boolean;
getAbsoluteFile(): File;
getAbsolutePath(): string;
getCanonicalFile(): File;
getCanonicalPath(): string;
getFreeSpace(): number;
getName(): string;
getParent(): string | null;
getParentFile(): File | null;
getPath(): string;
getTotalSpace(): number;
getUsableSpace(): number;
hashCode(): number;
isAbsolute(): boolean;
isDirectory(): boolean;
isFile(): boolean;
isHidden(): boolean;
lastModified(): number;
length(): number;
list(): string[] | null;
listFiles(): File[] | null;
static listRoots(): File[];
mkdir(): boolean;
mkdirs(): boolean;
renameTo(dest: File): boolean;
setExecutable(executable: boolean): boolean;
setExecutable(executable: boolean, ownerOnly: boolean): boolean;
setLastModified(time: number): boolean;
setReadable(readable: boolean): boolean;
setReadable(readable: boolean, ownerOnly: boolean): boolean;
setReadOnly(): boolean;
setWritable(writable: boolean): boolean;
setWritable(writable: boolean, ownerOnly: boolean): boolean;
toString(): string;
}

class FileWriter {
constructor(file: File);
constructor(file: File, append: boolean);
constructor(fileName: string);
constructor(fileName: string, append: boolean);

close(): void;
flush(): void;
getEncoding(): string | null;
write(c: number): void;
write(str: string, off?: number, len?: number): void;
}

class FileReader {
constructor(file: File);
constructor(fileName: string);

close(): void;
getEncoding(): string;
read(c: number): number;
read(cbuf: Uint8Array, off: number, len: number): number;
ready(): boolean;
}
}
}
}

0 comments on commit 0b9378d

Please sign in to comment.