How do I make so that when I input a value into a scanner if it is not an integer it won't give me an error? - java.util.scanner

I am writing a program that does simple math problems. What I am trying to do is to make it so that even if I input a string into the the scanner level it will not give me an error. The level is to choose the difficulty of the math problems. I have tried parseInt, but am at a loss of what to do now.
import java.util.Random;
import java.util.Scanner;
public class Test {
static Scanner keyboard = new Scanner(System.in);
static Random generator = new Random();
public static void main(String[] args) {
String level = intro();//This method intorduces the program,
questions(level);//This does the actual computation.
}
public static String intro() {
System.out.println("HI - I am your friendly arithmetic tutor.");
System.out.print("What is your name? ");
String name = keyboard.nextLine();
System.out.print("What level do you choose? ");
String level = keyboard.nextLine();
System.out.println("OK " + name + ", here are ten exercises for you at the level " + level + ".");
System.out.println("Good luck.");
return level;
}
public static void questions(String level) {
int value = 0, random1 = 0, random2 = 0;
int r = 0, score = 0;
int x = Integer.parseInt("level");
if (x==1) {
r = 4;
}
else if(x==2) {
r = 9;
}
else if(x==3) {
r = 50;
}
for (int i = 0; i<10; i++) {
random1 = generator.nextInt(r);//first random number.
random2 = generator.nextInt(r);//second random number.
System.out.print(random1 + " + " + random2 + " = ");
int ans = keyboard.nextInt();
if((random1 + random2)== ans) {
System.out.println("Your answer is correct!");
score+=1;
}
else if ((random1 + random2)!= ans) {
System.out.println("Your answer is wrong!");
}
}
if (score==10 || score==9) {
if (score==10 && x == 3) {
System.out.println("This system is of no further use.");
}
else {
System.out.println("Choose a higher difficulty");
}
System.out.println("You got " + score + " out or 10");
}
else if (score<=8 && score>=6) {
System.out.println("You got " + score + " out or 10");
System.out.println("Do the test again");
}
else if (score>6) {
System.out.println("You got " + score + " out or 10");
System.out.println("Come back for extra lessons");
}
}
}

The first error I see is that you tried to Integer.parseInt() a String "level" instead of the String variable named level
int x = Integer.parseInt("level");
should be
int x = Integer.parseInt(level);
Also, when defining level you can use keyboard.nextInt instead of keyboard.nextLine
String level = keyboard.nextInt();
Then, you wouldn't have to do an Integer.parseInt() operation later on

Related

Error: no suitable method found for length(int)

First time posting a question. Maybe I'm just being an idiot that's not seeing the problem, but can anyone identify what's wrong with my code below? Everything else works fine. But when the code is done compiling, it says "Error: no suitable method found for length(int)" for if (l.length(0)) and if (f.length(0)).
import java.util.Scanner;
public class Project2 {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int salary;
double savingsRate;
double interestRate;
int employmentYears;
double retirementSavings;
System.out.println("Enter input salary savings_rate interest_rate years_employed lastname firstname");
salary = scnr.nextInt();
savingsRate = scnr.nextDouble();
interestRate = scnr.nextDouble();
employmentYears = scnr.nextInt();
String l = scnr.nextLine(); // Last Name
String f = scnr.nextLine(); // First Name
retirementSavings = employmentYears * savingsRate * salary * (1 + interestRate);
if (salary < 0) {
System.out.println("Salary is negative");
}
else if (salary > 1000000) {
System.out.println("Error: Salary " + salary + "exceeds maximum 1000000.0");
}
else {
System.out.println("Salary: " + salary);
}
if (savingsRate < 0) {
System.out.println("Savings rate is negative");
}
else if (savingsRate > 0.5) {
System.out.println("Error: Savings rate " + savingsRate + "exceeds maximum 0.5");
}
else {
System.out.println("Savings Rate:" + savingsRate);
}
if (interestRate < 0) {
System.out.println("Interest Rate is negative");
}
else if (interestRate > 0.25) {
System.out.println("Error: Interest Rate " + interestRate + "exceeds maximum 0.25");
}
else {
System.out.println("Interest Rate: " + interestRate);
}
if (employmentYears < 0) {
System.out.println("Years employed is negative!");
}
else if (employmentYears > 50) {
System.out.println("Error: Years employed " + employmentYears + "exceeds maximum 50");
}
else {
System.out.println("Years of Employment: " + employmentYears);
}
if (l.length(0)) {
System.out.println("Error: Name too short");
}
else if (l == f) {
System.out.println("Error: Last Name and First Name are the same");
}
else {
System.out.println("Last Name: " + l);
}
if (f.length(0)) {
System.out.println("Error: Name too short");
}
else {
System.out.println("First Name: " + f);
}
System.out.println("Retirement Savings: " + retirementSavings);
}
}
I think you are trying to check if the name is empty, Am I right?
you have:
1) string.length() : length() method is a final variable which is applicable for string objects. length() method returns the number of characters presents in the string.
2) array.length : length is a final variable applicable for arrays. With the help of length variable, we can obtain the size of the array.
(visit geeksforgeeks to see more).
But you don't have a String.length(int) method.

Azure function not working properly after deployed [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a barcode function which is working great in local environment. But random requests are not working correctly after deploying the barcode to azure.
I have downloaded the demo EAN13 barcodefont and tried with below code to print the barcode.
If I request multiple request in local environment it's working correctly. After deployed to Azure when we request multiple request at a time it's returning wrong barcode randomly. For example failure cases 3 out of 10 request.
c# BarCode Function
public string GenerateBarCodeFont(string barCodeTextP, out bool isError, int widthP = 0, int heightP = 0, string fontNameP = "", int fontP = 0)
{
isError = false;
aa:
try
{
fontArray = new byte[0];
dataLength = 0;
if (widthP == 0)
widthP = 1;
if (heightP == 0)
heightP = 1;
if (fontP == 0)
fontP = 16;
fontArray = VLCEANThirtenBarCode.Properties.Resources.UPCEAN_0;
dataLength = VLCEANThirtenBarCode.Properties.Resources.UPCEAN_0.Length;
barCodeText = EAN13(barCodeTextP);
IntPtr destination = Marshal.AllocCoTaskMem(dataLength);
Marshal.Copy(fontArray, 0, destination, dataLength);
uint pcFonts = 0;
AddFontMemResourceEx(destination, (uint)fontArray.Length, IntPtr.Zero, ref pcFonts);
PrivateFontCollection fonts = new PrivateFontCollection();
fonts.AddMemoryFont(destination, dataLength);
Marshal.FreeCoTaskMem(destination);
this.ff = fonts.Families[0];
int num3 = heightP * 2;
int num5 = Convert.ToInt32((double)(Convert.ToDouble(widthP) * 1.5));
int num6 = (heightP * 100) / 90;
Font font = new Font(this.ff, (float)fontP);
PointF point = new PointF(2f, 2f);
Bitmap bitmap = new Bitmap(widthP, heightP, PixelFormat.Format24bppRgb);
bitmap.SetResolution((float)num6, (float)num6);
Graphics graphics = Graphics.FromImage(bitmap);
graphics.FillRectangle(new SolidBrush(Color.White), 0, 0, widthP, heightP);
graphics.DrawString(barCodeText, font, new SolidBrush(Color.Black), point);
using (MemoryStream stream = new MemoryStream())
{
bitmap.Save(stream, ImageFormat.Png);
byte[] inArray = stream.ToArray();
Convert.ToBase64String(inArray);
barCodeText = Convert.ToBase64String(inArray, 0, inArray.Length);
}
bitmap.Dispose();
}
catch (Exception ex)
{
if (ex.Message == "A generic error occurred in GDI+.")
goto aa;
isError = true;
return ex.Message;
}
return barCodeText;
}
EAN13 BarCodefont logic
public string EAN13(string bcP)
{
string s = "", suppl = "", TempStrL = "";
int CountryFlagL = 0;
switch (bcP.Length)
{
case 12:
case 13:
s = bcP.Substring(0, 12) + CheckDigit(SYMB_EAN13, bcP.Substring(0, 12));
break;
case 14:
case 15:
s = bcP.Substring(0, 12) + CheckDigit(SYMB_EAN13, bcP.Substring(0, 12));
suppl = AddOn(bcP.Substring(bcP.Length - 2));
break;
case 17:
case 18:
s = bcP.Substring(0, 12) + CheckDigit(SYMB_EAN13, bcP.Substring(0, 12));
suppl = AddOn(bcP.Substring(bcP.Length - 5));
break;
}
TempStrL = GetChar(digitsOnly, s.Substring(0, 1));//
TempStrL = TempStrL + "{{{{{";
TempStrL = TempStrL + "|";
CountryFlagL = Convert.ToInt32(s.Substring(0, 1));//
for (int i = 1; i <= 6; i++)
{
if (GetParity(SYMB_EAN13, i - 1, CountryFlagL) == "A")//
TempStrL = TempStrL + GetChar(charsetA, s.Substring(i, 1));//
else
TempStrL = TempStrL + GetChar(charsetB, s.Substring(i, 1));//
}
TempStrL = TempStrL + "{" + "|" + "{";
for (int i = 8; i <= 13; i++)
{
TempStrL = TempStrL + GetChar(charsetC, s.Substring(i - 1, 1));
}
TempStrL = TempStrL + "|";
if (suppl.Length > 0)
TempStrL = TempStrL + "}" + suppl;
return TempStrL;
}
protected string AddOn(string bcP)
{
string parL, ParSectionL = "", TempstrL;
int TotalL = 0, intbcL, MultiplierL, PositionL, CounterL = 0, SectLengthL;
switch (bcP.Length)
{
case 2:
parL = "AA" + "AB" + "BA" + "BB";
intbcL = Convert.ToInt32(bcP);
TotalL = intbcL % 4;
ParSectionL = parL.Substring(TotalL * 2, 2);
break;
case 5:
parL = "BBAAA" + "BABAA" + "BAABA" + "BAAAB" + "ABBAA" + "AABBA" + "AAABB" + "ABABA" + "ABAAB" + "AABAB";
for (int i = 1; i <= 5; i++)
{
MultiplierL = 3;
if (i % 2 == 0)
MultiplierL = 9;
intbcL = Convert.ToInt32(bcP.Substring(i - 1, 1));
TotalL = TotalL + MultiplierL * intbcL;
}
PositionL = (TotalL % 10) * 5;
ParSectionL = parL.Substring(PositionL, 5);
break;
}
TempstrL = "m";
SectLengthL = ParSectionL.Length;
for (int i = 1; i <= SectLengthL; i++)
{
if (ParSectionL.Substring(i - 1, 1) == "A")
TempstrL = TempstrL + GetChar(CharsetASupp, bcP.Substring(i - 1, 1));
else
TempstrL = TempstrL + GetChar(CharsetBSupp, bcP.Substring(i - 1, 1));
if (i < SectLengthL)
TempstrL = TempstrL + "n";
}
return TempstrL;
}
protected string CheckDigit(int SymbologyL, string c)
{
string s = "";
int NumDigitsL = 0, intc = 0, cd;
decimal TotalL = 0;
switch (SymbologyL)
{
case SYMB_UPCA:
NumDigitsL = 11;
break;
case SYMB_EAN13:
NumDigitsL = 12;
break;
case SYMB_EAN8:
NumDigitsL = 7;
break;
}
for (int i = 1; i <= NumDigitsL; i++)
{
if (((NumDigitsL + 1 - i) % 2) == 0)
{
string str = c.Substring(i - 1, 1);
intc = Convert.ToInt32(str);
TotalL = TotalL + 1 * intc;
}
else
{
string str = c.Substring(i - 1, 1);
intc = Convert.ToInt32(str);
TotalL = TotalL + 3 * intc;
}
}
cd = 10 - Convert.ToInt32(TotalL % 10);
if (cd == 10)
cd = 0;
return cd.ToString();
}
protected string GetChar(string c, string DigitP)
{
int intDigitL = Convert.ToInt32(DigitP);
return c.Substring(intDigitL, 1);
}
protected string GetParity(int SymbologyP, int PositionP, int CodeValP)
{
string parL = "", ParityL = "";
switch (SymbologyP)
{
case SYMB_EAN13:
parL = "AAAAAA" + "AABABB" + "AABBAB" + "AABBBA" + "ABAABB" + "ABBAAB" + "ABBBAA" + "ABABAB" + "ABABBA" + "ABBABA";
break;
case SYMB_UPCE:
parL = "BBBAAA" + "BBABAA" + "BBAABA" + "BBAAAB" + "BABBAA" + "BAABBA" + "BAAABB" + "BABABA" + "BABAAB" + "BAABAB";
break;
}
ParityL = parL.Substring(CodeValP * 6, 6);
return ParityL.Substring(PositionP, 1);
}
**Global Variables are below **
[DllImport("gdi32.dll")]
private static extern IntPtr AddFontMemResourceEx(IntPtr pbfont, uint cbfont, IntPtr pdv, [In] ref uint pcFonts);
FontFamily ff;
private string barCodeText = string.Empty;
byte[] fontArray;
int dataLength;
const int SYMB_UPCA = 1, SYMB_EAN13 = 3, SYMB_EAN8 = 4, SYMB_UPCE = 2;
string CharsetASupp = "+,./:;=?#K", CharsetBSupp = #"LMNOP[\]^_";
string charsetA = "ABCDEFGHIJ", charsetB = "QRSTUVWXYZ", charsetC = "0123456789", digitsOnly = "qrstuvwxyz";
The Correct one looks like below
The wrong one looks like below
I have created as vlcbarcode.dll file reference of above function and added the azure project same as refered url and written below function.
Below is the azure function
[FunctionName("GetBarCodes")]
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "GetBarCodes/")]HttpRequestMessage req, TraceWriter log)
{
log.Info("C# HTTP trigger function processed a request.");
// Get request body
VLCBarCodes[] barCodeList = await req.Content.ReadAsAsync<VLCBarCodes[]>();
List<QueryStringClass> resultList = new List<QueryStringClass>();
string errorText = "";
string result = "";
bool isError = false;
foreach (var list in barCodeList)
{
errorText = "";
result = "";
if (string.IsNullOrWhiteSpace(list.BarCodeFontType))
errorText = " Bar code Type can not be empty or null";
if (string.IsNullOrWhiteSpace(list.BarCodeValue))
errorText += " Bar code text can not be empty or null";
if (string.IsNullOrWhiteSpace(list.BarCodeFontHeight))
errorText += " Bar code height can not be empty or null";
if (string.IsNullOrWhiteSpace(list.BarCodeFontWidth))
errorText += " Bar code width can not be empty or null";
if (string.IsNullOrWhiteSpace(list.BarCodeFontSize))
errorText += " Bar code font can not be empty or null";
if (list.BarCodeImageUID == 0)
errorText += " Bar Code Image Id can not be empty or null";
if (string.IsNullOrWhiteSpace(list.BarCodeEntryNo))
errorText += " Bar Code entry no can not be empty or null";
if (!string.IsNullOrWhiteSpace(list.BarCodeFontType) && !string.IsNullOrWhiteSpace(list.BarCodeValue) && !string.IsNullOrWhiteSpace(list.BarCodeFontHeight)
&& !string.IsNullOrWhiteSpace(list.BarCodeFontWidth) && list.BarCodeImageUID != 0 && string.IsNullOrWhiteSpace(errorText))
{
switch (list.BarCodeFontType)
{
case "EAN-13":
GenerateEANTBarCode generateEANTBarCode = new GenerateEANTBarCode();
result = generateEANTBarCode.GenerateBarCodeFont(list.BarCodeValue, out isError, Convert.ToInt32(list.BarCodeFontWidth), Convert.ToInt32(list.BarCodeFontHeight), "EAN-13", Convert.ToInt32(list.BarCodeFontSize));
break;
default:
isError = true;
result = "Please specify the bar code font type";
break;
}
if (isError)
resultList.Add(new QueryStringClass { BarCodeEntryNo = list.BarCodeEntryNo, BarCodeImageUID = list.BarCodeImageUID, Type = list.BarCodeFontType, Value = "", ErrorText = result });
else
resultList.Add(new QueryStringClass { BarCodeEntryNo = list.BarCodeEntryNo, BarCodeImageUID = list.BarCodeImageUID, Type = list.BarCodeFontType, Value = result, ErrorText = "" });
}
else
resultList.Add(new QueryStringClass { BarCodeEntryNo = list.BarCodeEntryNo, BarCodeImageUID = list.BarCodeImageUID, Type = list.BarCodeFontType, Value = result, ErrorText = errorText });
}
return req.CreateResponse(HttpStatusCode.OK, resultList);
}
QueryStringClass can get the results from vlcbarcode.dll function and return to the end user.
public class QueryStringClass
{
public int BarCodeImageUID { get; set; }
//public Guid Guid { get; set; }
public string BarCodeEntryNo { get; set; }
public string Type { get; set; }
public string Value { get; set; }
public string ErrorText { get; set; }
}
VLCBarCodes class is refere to original calss fields to validate the request and send the values to .dll file function.
public class VLCBarCodes
{
public int BarCodeImageUID { get; set; }
public string BarCodeValue { get; set; }
public string BarCodeFontWidth { get; set; }
public string BarCodeFontHeight { get; set; }
public string BarCodeFontType { get; set; }
public string BarCodeFontSize { get; set; }
public string BarCodeEntryNo { get; set; }
}
Please suggest if I went anything wrong.
In Azure App service most of the GDI32 system calls are blocked.
All Azure Web Apps (as well as Mobile App/Services, WebJobs and Functions) run in a secure environment called a sandbox.
The sandbox generally aims to restrict access to shared components of Windows. Unfortunately, many core components of Windows have been designed as shared components: the registry, cryptography, and graphics subsystems, among others. This section outlines the limitations placed on usage of these often essential, yet shared components.
For the sake of radical attack surface area reduction, the sandbox prevents almost all of the Win32k.sys APIs from being called, which practically means that most of User32/GDI32 system calls are blocked. For most applications this is not an issue since most Azure Web Apps do not require access to Windows UI functionality (they are web applications after all).
Reference doc: https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox
You can host this Azure function in an Azure Virtual machine if you are willing to use same code else you can try some alternative approach to generate the BAR code as explained in this blog.

encoding and decoding a string

I need to write an application that fist converts a string to unicode and then add 2 to the unicode value to create a new string.
Basically, if the input is: password is RhYxtz, then the output should look like: rcuuyqtf ku TjAzvb
the following code is what I have so far:
public static void main(String[] args){
System.out.print ("Enter text: ");
Scanner scan = new Scanner(System.in);
String text = scan.nextLine();
int length = text.length();
for(int i = 0; i < length; i ++){
char currentChar = text.charAt(i);
int currentChar2 = currentChar+2;
String s = String.format ("\\u%04x", currentChar2);
System.out.println ("Encoded message: " + s);
}
}
The problem is that I don't know how to convert the unicode back into a letter string and how to keep the format the same as the input. Could anyone help me? Thanks.
Unicode code points can be gathered in java 8 as:
public static String encryped(String s) {
int[] cps = s.codePoints()
.mapToInt((cp) -> cp + 2)
.toArray();
return new String(cps, 0, cps.length);
}
or in a loop with codePointAt in earlier versions.
Java char (2 bytes) are UTF-16, and their int value is not always a Unicode symbol aka code point.
Try this:
import java.util.Scanner;
public class Example {
public static void main(String[] args) {
System.out.print ("Enter text: ");
Scanner scan = new Scanner(System.in);
String text = scan.nextLine();
int length = text.length();
String s = "";
for(int i = 0; i < length; i ++){
char currentChar = text.charAt(i);
if (currentChar == ' '){
s += currentChar;
} else {
s += (char) (currentChar + 2);
}
}
System.out.println ("Encoded message: " + s);
}
}
This should work for US ASCII letters:
StringBuilder buf = new StringBuilder(length);
for(int i = 0; i < length; i ++){
char currentChar = text.charAt(i);
if (currentChar < 128 && Character.isLetter(currentChar)) {
if (currentChar == 'y' || currentChar == 'z'
|| currentChar == 'Y' || currentChar == 'Z') {
buf.append((char) (currentChar + 2 - 26));
} else {
buf.append((char) (currentChar + 2));
}
} else {
buf.append(currentChar);
}
}
System.out.println(buf.toString());

How can I make int input to string input C#

How can I make int input to string input in C#? How can I change the int input to string input, so the user can write letters to the textbox, instead of numbers? I have tried myself, but the code won't work anymore. I know the solution is easy, but can't figure it out..
Here is my code:
public partial class MainWindow : Window
{
int[] arvat = new int[10];
int i = 0;
int k = 0;
public MainWindow()
{
InitializeComponent();
}
private void btnNimi_Click(object sender, RoutedEventArgs e)
{
int nimet = int.Parse( txtNimi.Text);
if (i < arvat.Length)
{
arvat[i] = nimet;
i++;
txtNimi.Text = "";
txtNimi.Focus();
}
else
{
MessageBox.Show("Kaikki arvat on syƶtetty.");
txtNimi.Text = "";
}
}
private void btnArpa_Click(object sender, RoutedEventArgs e)
{
int arpa = 0;
Random r = new Random();
arpa= r.Next(0, 9);
txbArvonta.Text = "";
for (int i = 0; i < arvat.Length; i++)
{
txbTeksti.Text = "\n" + "Kaikki osallistuneet: " + "\n";
txbArvonta.Text += arvat[i] + "\n";
int arpominen = arvat [k];
txbVoittaja.Text = "Ja voittaja on: " + arvat[arpa].ToString() + "\n" + "Onnea voittajalle!";
}
Instead of using Int.Parse, try using Int.TryParse to determine if the input will evaluate to a number before storing the result.
int number = 0;
bool isNumeric = Int32.TryParse(arvat[i], out number);
if (isNumeric)
{
Console.WriteLine("'{0}' is a number {1}.", arvat[i], number);
}
else
{
Console.WriteLine("'{0}' is text.", arvat[i]);
}

how to extract Paragraph text color from ms word using apache poi

i am using apache POI , is it possible to read text background and foreground color from ms word paragraph
I got the solution
HWPFDocument doc = new HWPFDocument(fs);
WordExtractor we = new WordExtractor(doc);
Range range = doc.getRange();
String[] paragraphs = we.getParagraphText();
for (int i = 0; i < paragraphs.length; i++) {
org.apache.poi.hwpf.usermodel.Paragraph pr = range.getParagraph(i);
System.out.println(pr.getEndOffset());
int j=0;
while (true) {
CharacterRun run = pr.getCharacterRun(j++);
System.out.println("-------------------------------");
System.out.println("Color---"+ run.getColor());
System.out.println("getFontName---"+ run.getFontName());
System.out.println("getFontSize---"+ run.getFontSize());
if( run.getEndOffset()==pr.getEndOffset()){
break;
}
}
}
I found it in :
CharacterRun run = para.getCharacterRun(i)
i should be integer and should be incremented so the code will be as follow :
int c=0;
while (true) {
CharacterRun run = para.getCharacterRun(c++);
int x = run.getPicOffset();
System.out.println("pic offset" + x);
if (run.getEndOffset() == para.getEndOffset()) {
break;
}
}
if (paragraph != null)
{
int numberOfRuns = paragraph.NumCharacterRuns;
for (int runIndex = 0; runIndex < numberOfRuns; runIndex++)
{
CharacterRun run = paragraph.GetCharacterRun(runIndex);
string color = getColor24(run.GetIco24());
}
}
GetColor24 Function to Convert Color in Hex Format for C#
public static String getColor24(int argbValue)
{
if (argbValue == -1)
return "";
int bgrValue = argbValue & 0x00FFFFFF;
int rgbValue = (bgrValue & 0x0000FF) << 16 | (bgrValue & 0x00FF00)
| (bgrValue & 0xFF0000) >> 16;
StringBuilder result = new StringBuilder("#");
String hex = rgbValue.ToString("X");
for (int i = hex.Length; i < 6; i++)
{
result.Append('0');
}
result.Append(hex);
return result.ToString();
}
if you are working on docx(OOXML), you may want to take a look on this:
import java.io.*
import org.apache.poi.xwpf.usermodel.XWPFDocument
fun test(){
try {
val file = File("file.docx")
val fis = FileInputStream(file.absolutePath)
val document = XWPFDocument(fis)
val paragraphs = document.paragraphs
for (para in paragraphs) {
println("-- ("+para.alignment+") " + para.text)
para.runs.forEach { it ->
println(
"text:" + it.text() + " "
+ "(color:" + it.color
+ ",fontFamily:" + it.fontFamily
+ ")"
)
}
}
fis.close()
} catch (e: Exception) {
e.printStackTrace()
}
}

Resources