| 1234567891011121314151617 |
- # 修复被 PowerShell Set-Content 添加 BOM 的 Java 文件
- $saasRoot = "d:\ylrz\ylrz_saas_his_scrm\fs-admin-saas\src\main\java\com\fs"
- $fixedCount = 0
- Get-ChildItem $saasRoot -Recurse -Filter "*.java" | ForEach-Object {
- $file = $_.FullName
- $bytes = [System.IO.File]::ReadAllBytes($file)
- # Check for UTF8 BOM (EF BB BF)
- if ($bytes.Length -ge 3 -and $bytes[0] -eq 0xEF -and $bytes[1] -eq 0xBB -and $bytes[2] -eq 0xBF) {
- # Remove BOM by reading as text and rewriting without BOM
- $content = [System.IO.File]::ReadAllText($file, [System.Text.Encoding]::UTF8)
- [System.IO.File]::WriteAllText($file, $content, (New-Object System.Text.UTF8Encoding $false))
- $fixedCount++
- }
- }
- "Fixed $fixedCount files with BOM"
|