-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImgToString.java
More file actions
51 lines (40 loc) · 1.39 KB
/
ImgToString.java
File metadata and controls
51 lines (40 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.io.*;
public class ImgToString{
protected String filePathway = new String();
protected String unformattedCode = new String();
// private String formattedCode = new String();
protected TextDetection textdetectionAPI = new TextDetection();
protected String outputType = new String();
// Constructor
public ImgToString(){};
public ImgToString(String filePathway){
this.filePathway = filePathway;
}
// Getters
public String getFilePathway(){ return filePathway; }
public String getUnformatted(){ return unformattedCode; }
// public String getOutputType(){ return outputType;}
// Modifier
public void setFilePathway(String s){ filePathway = new String(s); }
public void setOutputType(String s){ outputType = new String(s);}
public void exportAs(){
// outfile is the name of the file to be downloaded from user
PrintWriter outfile = null;
// unformattedCode = textdetectionAPI.detectText(filePathway);
try{
outfile = new PrintWriter("outfile.txt");
unformattedCode = textdetectionAPI.detectText(filePathway);
for(char ch: unformattedCode.toCharArray()){
outfile.append(ch);
}
} catch (FileNotFoundException e){
System.out.println(e.toString());
} catch (Exception e){
System.out.println("fuck this shit im so done");
} finally {
if (outfile != null){
outfile.close();
}
}
}
}