---
title: "windows迁到linux上斜杠的问题"
author: "xiajava2011"
date: "2013-06-25T13:46:40Z"
tags: []
categories: ["编程语言"]
slug: "windows-linux"
draft: false
lastmod: "2013-06-25T13:46:40Z"
id: 1893954
url: "https://xiajava2011.iteye.com/blog/1893954"
---

问题描述：

String path = request.getRealPath("/budget/bugetUpload") + "\\\\"+ fileName; 

FileOutputStream fs = new FileOutputStream(path);

在windows中没问题，在linux中不能创建文件，也不报错，原因是linux不能识别 \\

 

现改为：

String path = request.getRealPath(File.separator+"budget"+File.separator+"bugetUpload") + File.separator  
    + fileName;

File.separator能够根据当前系统自动识别，在

```
windows是\，unix是/
```