$path = "你的项目路径"
Get-ChildItem -Path $path -Recurse -Filter *.java | ForEach-Object {
$lines = Get-Content $_.FullName -Encoding UTF8
$output = @()
$modified = $false
foreach ($line in $lines) {
if ($line -match "int\s+getPersonno") {
$output += $line -replace "int\s+getPersonno", "long getPersonno"
$modified = $true
continue
}
if ($line -match "int\s+personno") {
$output += $line -replace "int\s+personno", "long personno"
$modified = $true
continue
}
$output += $line
}
if ($modified) {
[System.IO.File]::WriteAllLines($_.FullName, $output, [System.Text.Encoding]::UTF8)
Write-Host "文件已更新: $($_.FullName)"
} else {
Write-Host "文件未修改: $($_.FullName)"
}
}