Socket blocking on read operation while uploading zip file to the server

I am trying to upload a zip file to the server
Client thread creates the zip file ( of the modified files) and it even completes writing the data to the socket stream.
Now if the server thread tries to read the same data from the stream, it blocks on read operation.
While downloding the zip file from the server works fine.
Thanks in advance

You can use the URL object to upload it as multipart/form-data.
http://forum.java.sun.com/thread.jspa?threadID=579720&messageID=3997264
Or check out some of the file uploaders out there.
http://www.google.nl/search?hl=nl&q=site%3Asun.com+upload+applet&btnG=Zoeken&meta=

Similar Messages

  • How to upload a file to the server using ajax and struts

    With the following code iam able to upload a file ato the server.
    But my problem is It is working fine if iam doing in my system nd when iam trying to
    access theis application from someother system in our office which are connected through lan
    iam getting an error called 500 i,e internal server error.
    Why it is so???????
    Plz help me????????
    It is required in my project.
    I want the code to access from every system.
    My exact requirement is i have to upload a file to the server and retrive its path and show it in the same page from which we
    have uploaded a file.
    Here the file has to be uploaded to the upload folder which is present in the server.Iam using Tomcat server.
    Any help highly appreciated.
    Thanks in Advance
    This is my input jsp
    filename.jsp
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    <script type="text/javascript">
    alertflag = true;
    var xmlHttp;
    function startRequest(file1)
         if(alertflag)
         alert("file1");
         alert(file1);
    xmlHttp=createXmlHttpRequest();
    var video=document.getElementById("filepath").value;
    xmlHttp.open("POST","FilePathAction.do",true);
    xmlHttp.onreadystatechange=handleStateChange;
    xmlHttp.setRequestHeader('Content-Type', application/x-www-form-urlencoded');
    xmlHttp.send("filepath="+file1);
    function createXmlHttpRequest()
         //For IE
    if(window.ActiveXObject)
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
         //otherthan IE
    else if(window.XMLHttpRequest)
    xmlHttp=new XMLHttpRequest();
    return xmlHttp;
    //Next is the function that sets up the communication with the server.
    //This function also registers the callback handler, which is handleStateChange. Next is the code for the handler.
    function handleStateChange()
    var message=" ";
    if(xmlHttp.readyState==4)
         if(alertflag)
              alert(xmlHttp.status);
    if(xmlHttp.status==200)
    if(alertflag)
                                       alert("here");
                                       document.getElementById("div1").style.visibility = "visible";     
    var results=xmlHttp.responseText;
              document.getElementById('div1').innerHTML = results;
    else
    alert("Error loading page"+xmlHttp.status+":"+xmlHttp.statusText);
    </script></head><body><form >
    <input type="file" name="filepath" id="filepath" onchange="startRequest(this.value);"/>
    </form>
    <div id="div1" style="visibility:hidden;">
    </div></body></html>
    The corresponding action class is FIlePathAction
    package actions;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.*;
    public class FilePathAction extends Action{
         public ActionForward execute(ActionMapping mapping, ActionForm form,
                   HttpServletRequest request, HttpServletResponse response)
                   throws IOException, ServletException
              String contextPath1 = "";
              String uploadDirName="";
              String filepath="";
                        System.out.println(contextPath1 );
                        String inputfile = request.getParameter("filepath");
                        uploadDirName = getServlet().getServletContext().getRealPath("/upload");
                        File f=new File(inputfile);
    FileInputStream fis=null;
    FileOutputStream fo=null;
    File f1=new File(uploadDirName+"/"+f.getName());
    fis=new FileInputStream(f);
         fo=new FileOutputStream(f1);
                        try
         byte buf[] = new byte[1024*8]; /* declare a 8kB buffer */
         int len = -1;
         while((len = fis.read(buf)) != -1)
         fo.write(buf, 0, len);
                        catch(Exception e)
                                  e.printStackTrace();
                        filepath=f1.getAbsolutePath();
                        request.setAttribute("filepath", filepath);
                        return mapping.findForward("filepath");
    Action-mappings in struts-config.xml
    <action path="/FilePathAction"
                   type="actions.FilePathAction">
                   <forward name="filepath" path="/dummy.jsp"></forward>
              </action>
    and the dummy.jsp code is
    <%=request.getAttribute("filepath")%>

    MESSAGE FROM THE FORUMS ADMINISTRATORS and COMMUNITY
    This thread will be deleted within 24 business hours. You have posted an off-topic question in an area clearly designated for discussions
    about Distributed Real-time Java. Community members looking to help you with your question won't be able to find it in this category.
    Please use the "Search Forums" element on the left panel to locate a forum based on your topic. A more appropriate forum for this post
    could be one of:
    Enterprise Technologies http://forums.sun.com/category.jspa?categoryID=19
    David Holmes

  • How to Upload a File on the Server

    Hi,
    I want to upload a file on the server from Windows Mobile Application. Can anyone please suggest me a way to do so?
    Thanks in advance, 
    Saheli Sur

    Following links should also help
    http://blog.anthonybaker.me/2013/06/how-to-upload-file-from-windows-phone.html
    http://stackoverflow.com/questions/19954287/how-to-upload-file-to-server-with-http-post-multipart-form-data/20000831#20000831
    Gaurav Khanna | Microsoft .NET MVP | Microsoft Community Contributor

  • Problem when I upload txt files to the server

    Hi, I have a problem when I try to upload files to the server, and I can't understand the fail.
    My case is:
    I have a jsp page where a from is.
    This form is sended to a servlet that proccess its content and upload the attach file to the server.
    It works correctly (it uploads the files, txt, xls and csv), the problem is when I try to upload a txt file like this, for example:
    Depth     Age
    0     0,1
    2     0,9
    3     2
    5     6
    6     9
    8     12
    34     25
    56     39
    101     40When I verify the uploaded file, this one has a character extra of return of line (a small square). This character prevents me from working then correctly with the file, on having detected a column of more.
    Which can be the problem?
    The code I use to uploaded the file is:
    try
        MyConnection Objconnection = new MyConnection();
        boolean isMultipart = FileUpload.isMultipartContent(req);
        // Create a factory for disk-based file items
        FileItemFactory factory = new DiskFileItemFactory();
         // Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload(factory);
        // Set overall request size constraint
        upload.setSizeMax(1024*512); //524288 Bytes (512 KB)
         // Parse the request
        List items = upload.parseRequest(req);
        // Process the uploaded items
        Iterator iter = items.iterator();
        String dat = new String();
        String typeFile = new String();
        while (iter.hasNext())
            FileItem item = (FileItem) iter.next();
            if (item.getFieldName().equals("typeFile") )
                typeFile = item.getString();
            if (!item.isFormField())
            String fieldName = item.getFieldName();
            String fileName = item.getName();
            String contentType = item.getContentType();
            boolean isInMemory = item.isInMemory();
            long sizeInBytes = item.getSize();
            int numbers=0;
            for(int i=fileName.length();(i=fileName.lastIndexOf('\\',i-1))>=0;)
                 numbers++;
            String stringFile[] = fileName.split("\\\\");
            HttpSession session = req.getSession(true);
            String loginSesion = (String)session.getAttribute("UserLogin");
            String newUserFolder = loginSesion;
            File createFile = new File("/usr/local/tomcat/webapps/Usuarios/FilesUp/"+newUserFolder);
            if ("AgeModel".equals(typeFile))
                createFile = new File("/usr/local/tomcat/webapps/Usuarios/FilesUp/AgeModels/"+newUserFolder);
            if (!createFile.exists())
                createFile.mkdir();
            fileName = stringFile[numbers];
            File uploadedFile = new File("/usr/local/tomcat/webapps/Usuarios/FilesUp/"+newUserFolder+"/"+fileName);
            if ("AgeModel".equals(typeFile) )
                uploadedFile = new File("/usr/local/tomcat/webapps/Usuarios/FilesUp/AgeModels/"+newUserFolder+"/"+fileName);
            existe = Objconnection.existFile(fileName, typeFile, loginSesion);
            if ( true == existe )
                 exito = false;
            else
                item.write(uploadedFile);
                ....// NOW REGISTER THE FILE IN TH DATA BASE
        } // if (!item.isFormField())
    } // WHILE ( iter.hasNext() )
                catch(Exception e) {
                out.println("Error de Aplicaci�n " + e.getMessage());
                return exito;
    ...THANKS

    Hi,
    Sorry I am aware this question was posted way back, but I am having similar problem and haven't been able to find the fix yet.
    So please let me known if you have got any ideas.
    My problem is same that I have to upload a CSV file from Client Machine (Windows) to Unix Application Server.
    I am using JSP method post and multipart/form-data (as in http://www.roseindia.net/jsp/file_upload/Sinle_upload.xhtml.shtml).
    The file is uploaded fine but the problem is it displays carraige Return (^M) a square boxes on Unix file.
    I can't ask user to convert file to Unox format before uploading. They just convert excel file to CSV and upload.
    Is there any way I can get rid of these characters as I have to use this file further.
    Sorry, I can't use any paid utility or tool for it.
    I would appreciate if you could please help.
    Thanks,
    SW

  • How can I upload a file to the server where I save the Java Web Start Files

    Hello,
    Does anyone knows how to upload a file to the directory where I save the JAR files through the Java Web Start program. Thanks you

    ftp

  • Upload a file to the server - multipart/form-data ?

    I need to upload a file from my local machine to the server from a jsp page. I was asked to use a form with ENCTYPE = "multipart/form-data". but I am not sure how it works. Can any one enlighten me on the process or is there any other way to do it.
    null

    You can find the jsp source & the java sources which exactly does that in the iFS CMS sample code section. Go to Products -> Internet File system -> sample code -> Content Management System. This application allows the user to upload files from a local file system into iFS. This application creates the file in the iFS repository. You may want to save it in the file system of the web server. You may have to make little changes but the functionality is exactly what you are looking for.
    Hope this helps.
    Rajesh

  • Error while uploading indesign files to the cloud

    Hello,
    I have cs6 and when I want to drag'ndrop files to my cloud and error pops up.

  • Search Server is unavailable and could not be accessed While crawling .zip files

    I Have Search Service Application running in one of the Application Server in my Farm. I am using Continuous Crawl to Crawl My Local SharePoint Site Content Source. Today I looked at SearchServiceApp:CrawlLog-URl page and Found out following error message
    was encountered while crawling .zip files in the document library of a site.
    I checked my list of Allowed File types .zip is listed

    Hi octopus,
    According to your description, my understanding is that you got an error when you crawl zip files in SharePoint 2010.
    Whether this error occurred for all zip files in the entrie farm.
    Please disable the authentication loopback, then do a full crawl, compare the result.
    For disabling the authentication loopback, you can do as the followings:
    Click Start, click Run, type regedit, and then click OK.
    Locate and then click the following registry subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
    Right-click Lsa, point to New, and then click DWORD Value.
    Type DisableLoopbackCheck, and then press ENTER.
    Right-click DisableLoopbackCheck, and then click Modify.
    In the Value data box, type 1, and then click OK.
    Exit Registry Editor.
    Restart the computer.
    Here are two similar posts for your reference:
    http://sharepoint-kit.blogspot.jp/2013_08_01_archive.html
    http://suryapulipati.blogspot.jp/2013/10/the-sharepoint-item-being-crawled.html
    If this issue still exists, please check the log file to find more information about this issue. The path of the log file is: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS.
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Uploading a file to Portal server

    Hello all:
    First question: I'm creating an HTML page that uploads a file to the server using a form like this:
    When user fills the form and sends the file and error is showed:
    Application error occurred during request processing.
      Details:   Error [com.sap.engine.services.servlets_jsp.server.exceptions.WebServletException:
    Error in dispatching request to servlet /servlet/com.citas.Citas.], with root cause java.lang.NullPointerException: null.
    In the trace log file, appears an error message:
    #1.5#000F20CF176F00470003A2D300000D900004310A97BCC911#1179821471985#com.sap.ip.collaboration.rtc#sap.com/irj#com.sap.ip.collaboration.rtc.class com.sap.ip.collaboration.core.api.rtmf.core.RTMFMessaging.JMSPolling.startRunning()#anonymous#0##portald.huc.es_EP6_7205750#Guest#ea1ca07002d011dccf9a000f20cf176f#Thread[Thread-70,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Java###Exception in method: javax.jms.JMSSecurityException: You do not have permissions: action create_queue and instance ALL.
    #1#javax.jms.JMSSecurityException: You do not have permissions: action create_queue and instance ALL.
         at com.sap.jms.protocol.notification.ServerExceptionResponse.getException(ServerExceptionResponse.java:231)
         at com.sap.jms.client.session.Session.checkReceivedPacket(Session.java:2613)
         at com.sap.jms.client.session.Session.createQueue(Session.java:2442)
         at com.sap.ip.collaboration.core.api.rtmf.core.RTMFMessaging$JMSPolling.startRunning(RTMFMessaging.java:1130)
         at com.sap.ip.collaboration.core.api.rtmf.core.RTMFMessaging$JMSPolling.run(RTMFMessaging.java:1067)
         at java.lang.Thread.run(Thread.java:534)
    I think the error is caused by an authotization problem, but I don't know how to solve it.
    Second question: I'd like to know where is the default folder in the server where the files are uploaded in that way (HTML form). I don't know how to configure it. Maybe I could change permissions in it to allow Portal users to read/write in it.
    Thank all in advance. Regards,
    Alejandro Gómez.

    HI Alejandro
    Refer to this thread may be of some help to you .
    Authorization for JMS resources
    Thanx
    Pankaj

  • While transferring several files to the G-Raid, the G-Raid device locks up with the following warnings:   "The Finder can't complete the operation because some data in (whatever file) can't be read or written (Error code - 36)."

    While transferring several files to the G-Raid, the G-Raid device locks up with the following warnings:   "The Finder can't complete the operation because some data in (whatever file) can't be read or written (Error code - 36).” NOt sure this is a G-Raid problem, can anyone help?

    This is likely a problem with the drive itself. This error indicates unspecified I/O errors with the drive, which can be from a hardware fault, or a formatting issue. If the drive has valuable data on it, then try connecting it to another PC to get the data off, and then try fully partitioning and formatting the drive with Disk Utility. If this corrects the error then you should be able to use the drive again as it was likely a formatting issue, but if the problem continues then it is likely a hardware fault and the best solution is to be safe and replace the drive.

  • HELP!!! An asynchronous read operation is already in progress on the StandardOutput stream

    Hi everyone,
    I'm trying to use C# to control a command line application background, which can be downloaded here:
    http://www.ti.com/litv/zip/spmc015b
    This is an app for motor voltage control, when I enter the app, like "b.exe -c 1", the console seems a kind of blocking model. Every command in this app begins with "#" symbol. See pics below:
    What I'm trying to do is, use StandardInput.WriteLine("stat vout"); to measure the voltage. This will send a "stat vout" command to the console background and ideally return a voltage value. In this pic, it return some help hints. Duing all this time,
    it still in the blocking mode.
    I want to get the return message with StandardOutput.ReadLine(); but failed. If ReadToEnd() then my program is freezed because this app never return to standard console, which is blocking.
    When I tried BeginOutputReadLine(); OutputDataReceived event can truly obtain the message return from the console, like in the pics of "stat [vout|vbus|fault". But it limited in my single thread program.
    My current situation is that, I use System.Timers.Timers in WinForms and every second will send a  "stat vout2" command to read the voltage, and hopefully get the return value.
    However, the System.Timers.Timers is asynchronous, so when I called BeginOutputReadLine() in this Timers thread, it prompted "An async read operation has already been started on the stream." In the meantime, as I've demonstrated above, I cannot use synchronous
    methods like ReadLine() to get the value.
    So what should I do now? I truly need to run this command line app in multi-threading mode.
    Thanks so much and wish everybody has a nice weekend.

    public class SystemClock
        TimingController Timing = new TimingController();
        private Timer TimerSystemClock;
        public SystemClock()
            TimerSystemClock = new Timer();
            TimerSystemClock.Interval = 1000;
            TimerSystemClock.AutoReset = true;
            TimerSystemClock.Elapsed += new ElapsedEventHandler(TimerSystemClock_Elapsed);
            TimerSystemClock.Enabled = false;
            Timing.ClockInstance = this;
        public void Start()
            TimerSystemClock.Enabled = true;
        void TimerSystemClock_Elapsed(object sender, ElapsedEventArgs e)
            Timing.Measuring();
    public class TimingController
        // Get singleton of Measurement Class
        Measurement Measure = Measurement.GetInstance();       
        public SystemClock ClockInstance
            get { return Clock; }
            set { Clock = value; }
        private void Measuring()
            CurrentVoltage = Measure.GetVoltage();
            CurrentCurrent = Measure.GetCurrent();
    public sealed class Measurement
        // Singleton
        public static readonly Measurement instance = new Measurement();
        public static Measurement GetInstance()
            return instance;
        private Process ProcMeasuring = new Process();
        double measureValue
        bool isOutputObtained;
        private Measurement()
            ProcMeasuring.StartInfo.FileName = "b.exe";
            ProcMeasuring.StartInfo.Arguments = "-c 1";
            ProcMeasuring.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory();
            ProcMeasuring.StartInfo.UseShellExecute = false;
            ProcMeasuring.StartInfo.RedirectStandardInput = true;
            ProcMeasuring.StartInfo.RedirectStandardOutput = true;
            ProcMeasuring.StartInfo.RedirectStandardError = true;
            ProcMeasuring.StartInfo.CreateNoWindow = true;
            ProcMeasuring.OutputDataReceived += new DataReceivedEventHandler(MeasurementOutputHandler);
        public double GetVoltage(Machine machine)
            isOutputObtained = false;
            ProcMeasuring.StandardInput.WriteLine("stat vout2");
            ProcMeasuring.BeginOutputReadLine();
            while (!isOutputObtained)
                isOutputObtained = true;
            return measureValue;
        public double GetCurrent(Machine machine)
            isOutputObtained = false;
            ProcMeasuring.StandardInput.WriteLine("stat cur");
            ProcMeasuring.BeginOutputReadLine();
            while (!isOutputObtained)
                isOutputObtained = true;
            return measureValue;
        private void MeasurementOutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
            if (!String.IsNullOrEmpty(outLine.Data) && (outLine.Data != "# "))
                measureCurrentValue = Convert.ToDouble(outLine.Data);
                isOutputObtained = true;
                ProcMeasuring.CancelOutputRead();
    }

  • Uploading zip file to server

    Hi,
    I want to upload a zip file in some server location,till now i have below code,but not able to get any clue how to upload zip file to server when user press Begin button.
    Can someone please help me?
    >
    JSP code:
    <af:inputFile label="Upload:"
    valueChangeListener="#{ifarm.fileUploaded}"/>
    <af:commandButton text="Begin"/>
    Bean code :
    public void fileUploaded(ValueChangeEvent valueChangeEvent) {
    UploadedFile file = (UploadedFile) valueChangeEvent.getNewValue();
    if (file != null)
    System.out.println("************** "+file.getFilename().toString());
    >>

    All you need to do is to get hold of the input stream of the upload file and copy it to an file on your server (which you can create).
        public static int copy(InputStream input, OutputStream output)
                throws IOException {
            byte[] buffer = new byte[1024 * 4];
            int count = 0;
            int n = 0;
            while (-1 != (n = input.read(buffer))) {
                output.write(buffer, 0, n);
                count += n;
            return count;
        public void fileUploaded(ValueChangeEvent valueChangeEvent) {
            UploadedFile file = (UploadedFile)valueChangeEvent.getNewValue();
            if (file != null) {
                File ff;
                try {
                    // create a temporary file on the host server
                    ff = File.createTempFile("xx", "yy");
                    FileOutputStream os = new FileOutputStream(ff);
                    IOUtils.copy(file.getInputStream(), os);
                } catch (IOException e) {
                    e.printStackTrace();
                System.out.println("************** " +
                                   file.getFilename().toString());
        }Timo

  • Read a zip file from Application server.

    Hi,
    Is there a way to read a zip file from the applicatoin server to internal table in ABAP program?  The operation system is running MS windows server.  The zip file contains only 1 text file.  I tried to use open dataset 'uncompress', and use read dataset, but read dataset gave me sy-subrc = 4.  Any feedback is greatly appreciated.
    Thanks.

    hi,
    to convert xstring to text you can use this:
    DATA unzipped_data TYPE xstring.
    DATA text_data TYPE string.
    DATA conv_x2c TYPE REF TO cl_abap_conv_in_ce.
    conv_x2c = cl_abap_conv_in_ce=>create( ).
    conv_x2c->convert( EXPORTING input = unzipped_data IMPORTING data = text_data ).
    moreover, if you want to split your text at "end of line" (CR LF in microsoft windows) into lines:
    DATA text_lines TYPE TABLE OF string.
    SPLIT text_data AT cl_abap_char_utilities=>cr_lf INTO TABLE text_lines.

  • Getting error while uploading multiple files in sharepoint hosted app in 2013 with REST API

    Hi All,
    In one of my tasks, I was struck with one issue, that is "While uploading multiple files into custom list with REST API".
    Iam trying to upload multiple files in library with REST calls for an APP development, my issue is if i wants to upload 4 image at once its storing only
    3 image file and further giving "Conflict" error". Below is the attached screenshot of exact error.
    Error within screenshot are : status Code : 409
    status Text :conflict
    For this operation i am uploading different files as an attachment to an list item, below is the code used for uploading multiple files.
    my code is
    function PerformUpload(listName, fileName, listItem, fileData)
        var urlOfAttachment="";
       // var itemId = listItem.get_id();
        urlOfAttachment = appWebUrl + "/_api/web/lists/GetByTitle('" + listName + "')/items(" + listItem + ")/AttachmentFiles/add(FileName='" + fileName + "')"
        // use the request executor (cross domain library) to perform the upload
        var reqExecutor = new SP.RequestExecutor(appWebUrl);
        reqExecutor.executeAsync({
            url: urlOfAttachment,
            method: "POST",
            headers: {
                "Accept": "application/json; odata=verbose",
                "X-RequestDigest": digest              
            contentType: "application/json;odata=verbose",
            binaryStringRequestBody: true,
            body: fileData,
            success: function (x, y, z) {
                alert("Success!");
            error: function (x, y, z) {
                alert(z);

    Hi,
    THis is common issue if your file size exceeds 
     upload a document of size more than 1mb. worksss well for kb files.
    https://social.technet.microsoft.com/Forums/office/en-US/b888ac78-eb4e-4653-b69d-1917c84cc777/getting-error-while-uploading-multiple-files-in-sharepoint-hosted-app-in-2013-with-rest-api?forum=sharepointdevelopment
    or try the below method
    https://social.technet.microsoft.com/Forums/office/en-US/40b0cb04-1fbb-4639-96f3-a95fe3bdbd78/upload-files-using-rest-api-in-sharepoint-2013?forum=sharepointdevelopment
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Multiple languges used while uploading a file using java appn

    Hi everybody,
    i have a problem with multiple languages , let me clear you the question, i were developing a java application using spring ,hibernate frame works, so i got a problem while uploading a file with chinees language or other
    it was saving with different format other than chiness in the database, can any one help me out ... i need the exact language when i upload the files
    thank you very much

    Santhosh_25 wrote:
    actually i have asked the users for the languages... they told some languages like chinees,japanese,german,french,koriean,spanish,italian,dutch,russsian,englishThat isn't deterministic.
    Again, this is pointless unless it is deterministic.
    But lets say that each language group only uses a single character set.
    And each language group stores their files in a specific directory (or server).
    That allows you to deterministically identify the character set of the file.
    So you can then read each file by using a text reader from the java.io package with the correct encoding set.
    This works because it is determinstic.
    The following will NOT work.
    You have a directory with a bunch of files with completely random content in different languages. There is NO way to write a program that will correctly handle those.
    So, again, the first step before doing anything in java is figuring out how you will differentiate the different files.

Maybe you are looking for