I am using Java with Rest api to get file from Sharepoint online. It is okay but if the file contains Turkish character i can't get it.
If the file name is "test.pfd" , i can open the file but the file name is "İtest.pdf" i can't. Do you know how to get the file?
public void getTheFile(String sitePath, String path, String file) { try { String filePath = ProjectUtil.DESKTOP_PATH + file; Desktop desktop = Desktop.getDesktop(); File f = new File(filePath); Boolean goAhead = false; if (f.exists()) { Object[] options = { "Yes", "No" }; if (JOptionPane.showOptionDialog(null, "There is the same file on your desktop. Are you sure?", "Cancel", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]) == 0) { goAhead = true; } } else { goAhead = true; } if (goAhead) { String siteURL = "https://" + SHAREPOINT_HOST + "/" + sitePath; String wsUrl = siteURL + "/_api/web/GetFolderByServerRelativeUrl('" + path + "')/Files('" + file+ "')/$value"; System.out.println(wsUrl); // Create HttpURLConnection URL url = new URL(wsUrl); System.out.println(url.toString()); URLConnection connection = url.openConnection(); HttpURLConnection httpConn = (HttpURLConnection) connection; // Set Header httpConn.setRequestMethod("GET"); httpConn.setDoInput(true); httpConn.setDoOutput(true); httpConn.setRequestProperty("content-type", "application/json; charset=utf-8"); httpConn.setRequestProperty("Authorization", "Bearer " + AUTH_TOKEN); // Read the response String httpResponseStr = ""; InputStreamReader isr = null; if (httpConn.getResponseCode() == 200) { Files.copy(httpConn.getInputStream(), Paths.get(ProjectUtil.DESKTOP_PATH, file),StandardCopyOption.REPLACE_EXISTING); //title="ModifiedBy" desktop.open(f); } else { isr = new InputStreamReader(httpConn.getErrorStream()); BufferedReader in = new BufferedReader(isr); String strLine = ""; while ((strLine = in.readLine()) != null) { httpResponseStr = httpResponseStr + strLine; } System.out.println(httpResponseStr); } } } catch (Exception e) { System.out.println("Error while reading file: " + e.getMessage()); } }