Can Someone help me to convert my Python Code to Java Code please?

My Python Code :

def import_file(file):
    with open(file,"r") as f:
        lines = f.readlines()
        sline = []
        for line in lines:
          xline=line.split(" ")
          sline.append(xline)
    return sline

def set_file(idf,q,sline):
    for i in sline:
        if idf in i:
            sline[sline.index(i)][1] = q + "\n"
            return "Change succeeded"
    sline.append([idf,q])
    return "New code added"

def list_file(idf,sline):
    for i in sline:
        if idf in i:
            return sline[sline.index(i)][1]
    return "Not found"

def export_file(name,sline):
    with open(name,'w') as f:
        for lines in sline:
            f.write(lines[0] + ' ' + lines[1])

loop = 1
while loop == 1:
    choice=int(input("1:Import file\n 2:Set \n 3:List \n 4:Export file \n 5:Quit \n :"))
    if choice == 1:
        print("Importing file...")
        use=import_file(input("Insert the path of the file:"))
    elif choice == 2:
        print("Setting file...")
        print(set_file(input("Insert id:"),input("Insert quantity:"),use))
    elif choice == 3:
        print("Listing file...")
        print(list_file(input("Insert id:"),use))
        print(use)
    elif choice == 4:
        print("Exporting file...")
        print(export_file(input("Name of the exported file:"),use))
    elif choice == 5:
        print("Goodbye")

    loop = 0
import base64, os
 import pymongo
 import bson
from pathlib import Path
import json
from pymongo import MongoClient
import csv
client = MongoClient('mongodb://localhost:27017/',maxPoolSize=500000, unicode_decode_error_handler='ignore')
with client:
 #db = client.dbname
 with open(r'D:\\GO_FOUND_MIGRATION\\IMAGE_FILE.csv',"r") as csv_file:
      csv_reader = csv.reader(csv_file, delimiter=',')
     #next(csv_reader)
      for lines in csv_reader:
          print("The ticket processing is",lines[2])
          file_used = lines[1]
          with open(file_used, 'rb') as fout:
               try: 
                string = base64.b64encode(fout.read())
                if lines[3] == "go_support":
                   db = client.dbname  
                   support_col = db.case_details
                   support_col.update_one({"case_id" : lines[2] },{"$set":{"attachment_image" : string}})
                   print("Inside first loop",lines[3])
                   print("Inside id ",lines[0])
                   #print("printing binary value",string)                       
                else:
                   db = client.dbname  
                   support_col = db.case_history
                   support_col.update_one({"case_id" : lines[2] },{"$set":{"attachment_image" : string}})
                   print("Inside else part",lines[3])
                   #print("Inside id ",lines[0]) 
               except Exception as exception:
                  print("Exception~~",exception)
                  continue
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.